00:01
All right, for this problem, we're going to enter a decimal number and convert it to a hexadecimal, which is base 16.
00:13
So hopefully you've got a good fill for what base 16 looks like.
00:16
If not, hopefully this will help.
00:18
So we're going to say enter a decimal integer, and we get that decimal integer from the user, and then i'm going to go ahead and just create a variable called hexnum and i'll make it, oops, make it a string and that'll be the output.
00:42
And so i'm just going to keep processing decimal number and making it smaller, processing, making smaller.
00:49
Eventually it'll be zero.
00:51
So i'm going to say while decimal number is greater than zero, that means i'm not done yet.
01:01
All right.
01:07
So i'm going to go ahead and use a variable called bit.
01:13
I don't need it outside of the while loop.
01:18
And so bit is equal to decimal number.
01:21
If i divide decimal number by 16, bit is going to be the remainder.
01:27
And then i'm going to say bit string is equal to, i'm going to convert that.
01:37
Bit value, oops if i spell number right, occurred that bit value into a string.
01:45
And so now if you know hexadecimal though, it's possible when i divide 27 by 16, i'm gonna have 11 left over and i don't want to print out an 11 because that's gonna get really confusing.
02:00
And so i need to just do a series of if statements.
02:03
We could do lfs if we wanted.
02:06
That's probably a little bit more efficient.
02:10
But if the bit value is equal to 10, then bit string is equal to a.
02:23
And i need to type all these down.
02:25
I'm going to go ahead and use some copy and paste.
02:28
So that's for 10, 11.
02:31
Ooh, let me undo that a little bit.
02:34
Let me add a that.
02:36
So now i can go to here.
02:38
I don't think that's going to work either.
02:42
Yeah, i don't like that.
02:42
I can fix that.
02:44
So that's 10, 11, 12, 13, 14, 15...