How to Convert Decimal Fractions to Binary (and Back!) – Easy Step-by-Step Guide

Struggling with converting decimal fractions to binary? In this fun, beginner-friendly tutorial, we dive into how to convert numbers like 45.8046875 to binary and back to decimal, step by step! Learn the multiplying-by-2 method, handle precision loss, and understand fractional binary representation. With real examples (0.126753, 0.84375), you’ll master this key computer science skill. Perfect for students, coders, or anyone curious about how computers store numbers. Subscribe for more tech tutorials, and let me know what you want to learn next! Visit [YourWebsiteLink] for more. #Binary #DecimalToBinary #ComputerScience #TechTutorials

Introduction to Decimal-Binary Conversion 00:00:00
Understanding Fractional Binary Numbers 00:00:15
Fractional Binary Representation Basics 00:01:00
Converting Decimal Fractions to Binary 00:04:06
Example: Converting 0.126753 to Binary 00:04:52
Precision Loss in Conversions 00:05:36
Example: Converting 0.84375 to Binary 00:09:57
Converting Binary Fractions to Decimal 00:14:22
Example: Converting Complex Number 45.8046875 00:16:48
Combining Whole and Fractional Parts 00:21:00
Conclusion and Verification 00:23:25
Outro and Community Engagement 00:24:16

Thanks for watching!

Find us on other social media here:

  • https://www.NeuralLantern.com/social

Please help support us!

  • Subscribing + Sharing on Social Media
  • Leaving a comment or suggestion
  • Subscribing to our Blog
  • Watching the main “pinned” video of this channel for offers and extras

Hello there, let’s talk about how to convert decimal numbers with fractions into binary

numbers with fractions and vice versa.

So up to this point, if you’ve been watching my other videos, you probably know that you

can easily convert a decimal number to binary and binary to decimal if the decimal and binary

numbers but in order to progress towards IEEE 754 representation in other words

in order to eventually be able to represent binary numbers with fractions

like floats or doubles in the machine you have to start learning how to get

the fraction part of a decimal number into binary the way we’re going to do

it in this video it’s not actually going to be the final representation of how

your machine stores floating point numbers but it’s an important step on

on the way there. Without this step, you probably wouldn’t be able to do it.

So what am I talking about? I’m just going to open up this notepad real fast and just show you

that what I really mean is, suppose we have like a number 45 point blah, blah, blah, blah, blah,

right? So this is the whole part and this is the fractional part. Okay, no problem. Also in binary,

we have like a bunch of ones and zeros. This is a whole number, but we could put a decimal point

and then just start doing more numbers after the decimal point in order to represent a

in order to represent a fractional binary number.

Okay, so let’s see.

We know, hopefully at this point, if you watch my other videos,

that, I don’t know, I’m just going to put some random numbers here

and then like some more random numbers there.

And you know that the strength of each of these numbers

is sort of like increasing by powers of two on the left side, on the whole side.

So the strength of that first digit is one.

digit is one the next digit has a strength of two and then four and then eight and then 16 maybe i’ll

put the six up here and then 32 so three and two and then 64 and maybe i’ll do another digit i’ll

just put like a zero there and then you know the left most digit has a strength of 128 so basically

a 1 or a 0 for the actual binary number multiplied by its strength. So 1 times 1 is 1, add that to

0 times 2, add that to 1 times 4, and 0 times 8, and 1 times 16, and so forth, right? So hopefully

we know how to do that at this point. To do the same thing on the fractional side, maybe I won’t

put a decimal marker there, it’s really the same deal except as we go left, we were multiplying by

have more power more strength but as we go to the right past the decimal point they should have less

strength and we’ll just divide them by two so pretty much at this point let’s see we’ll have

one half will be the strength of this digit right here whoops one half so the strength that that

digit has is just one half the strength that the next digit has is going to be one fourth remember

1 4th remember you multiply sorry you divide by 2 each time whoops I’m getting lost oh man I

probably need to add some spaces because it’s starting to get pretty ugly so this digit has

a strength of 1 half this digit has a strength of 1 4th and then we’ll just say that the next one

has a strength of 1 8th and so forth we’ll just keep dividing by 2 each time so don’t forget that

don’t make the mistake of saying 1 4th or sorry don’t make the mistake of saying 1 half 1 3rd

one half, one third, one fourth.

Don’t increase the denominator by one.

You want to multiply, or sorry,

you want to divide by two each time.

Or if you want to say the word multiplication,

then you multiply by 0.5, I guess, if you want to.

I’m just going to write 1 16th

and then just be done with the divisions.

I hope you understand what I’m talking about.

We’re going to do some examples right now.

Okay, so let’s calculate.

Well, actually, let’s just, just to emphasize, just to make sure everybody understands, what

we would do to convert such a number from binary to decimal would basically be, you

know, compute the left side as if it were a whole number.

I’m going to put W for whole number.

And then separately convert the fractional part as if it were just, you know, zero point

something.

And then just combine the two things when you’re in decimal.

And you’ll do the same thing when converting a number from decimal to binary.

decimal to binary you convert the whole part first put that into ones and zeros then convert the fact

the fractional part into a fractional binary part and then just combine them across the decimal point

so let’s do an example let’s start with converting 0.126753 i don’t think that this number is going

to resolve easily it’s kind of like a good lesson here when you’re converting between binary and

there are always going to be some numbers in in in decimal that you can’t represent in binary

and vice versa there are always going to be some numbers in binary that you can’t represent in

decimal so it’s not that decimal or binary or you know superior or inferior i mean all technology

is pretty much running on binary so it can’t be that bad but um just keep that in mind some numbers

that you type randomly are just never going to resolve and you’ll have to give up at some point

have to give up at some point and say, well, we’re just going to call this a precision loss

because we just, we just have to like give up, especially if you only have so many bits

to put the fraction in. Okay. So what am I going to do? What’s the, what’s the basic algorithm

here? There are lots of different ways to do it. The way that I’m going to show you is just

multiplying by two. So if we take, you know, 0.126753 and we multiply it by two,

We end up with, let’s see, times 2.

Whoops, hello.

Oh, I got to do that.

Times 2.

We’re going to end up with a different number.

If the number is equal to or greater than 1,

then we will say that we have achieved a number of 1 for the converted binary number.

And if not, we’ll say we have achieved a number of 0.

If the number is 1, we’ll also subtract 1 from the remaining number here in decimal.

The result we have is just, what’s going on?

Oh, I somehow turned on my annotator.

Okay.

In this case, we just have, you know, this number right here.

It’s not greater than one or equal to one.

So I’m just going to say this gave us a binary number of zero.

And because it gave us a zero, we’re not actually going to change it at all.

We’re not going to subtract one from it.

We’re just going to leave it as is.

We will then multiply by two again.

by 2 again. So I’m just going to say, do it one more time. We’ll say this multiplied by 2,

and it’s going to be this number. Again, it did not exceed or equal 1, so the bit in that position

is going to be a 0, and we’ll just copy and carry it over just as is. Do it again, and we’ll say

Now we have a number that equals or exceeds one.

So we’ve achieved a one in the binary position.

So it’s going to be a one here.

Then we got to subtract one.

So we’re just going to be left with 0.014, 024 and whatever.

And then we just continue.

Maybe I’ll do it a couple more times,

but I’m going to give up because I don’t think

that this number will translate completely.

So I’m going to say multiply by two again,

and it’s going to give us,

hang on a second here.

What was that?

Hang on a second here. What was that? That was one. Oh, I forgot to subtract one. So I got to

subtract one. And then I’m going to multiply by two. Now we get this number right there.

This is not equal to or greater than one. So the bit is going to be zero.

And then that means the remaining number is just going to be the same thing.

We’ll do another. Actually, let me let me clean the calculator for a second here.

going to select this whole thing and just paste that and I’m going to say

multiplied by two that’s going to be that new number and I think you’re

starting to understand why I want to give up because we’ll just be kind of

doing this forever this might end up being an irrational number in binary I

don’t really know I haven’t gone that far but it’s definitely gonna take a long

time so I’m gonna give up and I’m just gonna say all right the final binary

number is gonna be 0.00100 and then just say maybe there’s some more stuff at

maybe there’s some more stuff at the end we’ll just call this a precision loss

you can see well maybe I should do one more number actually because it it’s kind of a mirror there’s

like two zeros and then a one and then two zeros on the other side let me multiply this by two

real fast just to show you without symmetry what would happen so I’m gonna multiply that by two

and it’s gonna be this number right here so that’s gonna be zero because it didn’t exceed

or meet one and so the number we have left over is just that okay so now

because there’s no symmetry you can see that the number is going to be point

zero zero one zero zero zero we go from top to bottom we don’t do any kind of

reversal like you might do with whole number binary conversion I don’t know

maybe it’ll be zero for a long long long long time and never or yeah they’ll

probably be some ones in there at least I don’t know if it’s ever going to

resolve you’ll know you’re finished when the

Here is a zero.

So again, I’m just going to give up on this because I don’t really know if it’s going to work.

Let’s do a number that I know is going to resolve.

I have this one prepared in advance.

So let’s do 0.84375.

Okay.

So how do we convert this?

Again, just multiply by two.

Every single time you meet or exceed one, then you’ll say that we have a one in the binary number.

binary number and then subtract one after that and if not we will say that

we have a zero in the binary position and then we won’t subtract one okay so

that number multiplied by two is going to be point one six eight seven five so

that’s definitely greater than or equal to one so I’m going to say we have a one

in the binary position and then the next number is going to be just be zero point

now we take that number 6875 you could also just you know in your calculator you could say minus

one and then we’ll multiply it by two to get the next bit the number is going to be 1.375 so i’m

going to write 1.375 here and then it’s greater than or equal to one so it’s going to be another

one here and then after we subtract one it’s going to be 375 no problem okay so let me just

And then multiply by 2 to get to the next bit position.

It’s going to be 0.75.

All right, so 0.75, that number is less than 1, so we have a 0 in that bit position.

We also don’t subtract anything because we had a 0 in that bit position.

Then we just multiply by 2 again.

Multiply by 2, now we have 1.5 because that’s greater than or equal to 1.

We have a 1 in that bit’s position, then we subtract 1.

one it’s just going to be 0.5 that should be pretty easy right because that’s that sounds

like there’s a one in a bit and then it’s just done after that so i’m going to do minus one

and then multiply by two again notice how that is exactly a one so it’s going to be 1.0

which means we have a one in the position because it is equal to or greater than one

and then uh well what we have left over is zero

Zero multiplied by two is going to be zero.

So that means if we kept doing this forever,

then all the numbers down here are just going to be zeros forever.

And I said in another video,

when you realize what’s going on with the zeros,

like where are they?

Are they on the left or the right?

When you’re converting a whole number from binary to decimal or decimal to binary,

the zeros would be on the left side.

So that’s why we would reverse

because if you just add infinity zeros on the left of a whole number,

you’re not changing the value.

number you’re not changing the value but if you added them to the right you’d be increasing the

value when it comes to the fractions the right side of the fraction won’t change the number for

example if we had you know one point and then some like random binary numbers if we just kept adding

zeros on the right side that’s not changing the value of the number because this is the fractional

part however if we started adding numbers on the left side then we would make the fractional part

smaller and smaller and smaller so that means the zeros have to be on the right side and you can see

and you can see here the right side is the bottom so that means we’re going to take these numbers

I’ll just put etc here just so you can see etc that means we’re going from top to bottom so the

final number is 0.11011 and then a bunch of zeros after that are just you know nothing

and that’s the final answer we now have 0.84375 is equal to binary that number and we’ll just say

that number and we’ll just say OB to to indicate that the following is a binary

number because again you could have a decimal number and then have like a

bunch of like ones and zeros in the fraction part I guess so to make sure

that the reader understands what they’re seeing you’ll say OB to indicate this is

a binary number on exams or quizzes if you’re out there doing this for an exam

or a quiz keep in mind you probably want to talk to professor to make sure that

ob is supposed to be part of your answer they might just want this it depends anyway so 0.11011

okay then let’s convert it back again let’s let’s convert this number to the original decimal number

there okay so how can we do that pretty much just start adding the fractions up so remember the

Remember, the first fraction that we see is going to be one half.

One half.

And the second fraction we see is going to be one fourth.

And then we just keep multiplying.

One fourth, one half.

Maybe I should write this in a notepad here.

We’ll see one half plus one fourth plus one eighth.

And some of these bits aren’t going to count.

Like, for instance, the one eighth, it’s not going to count towards the fraction.

But for me personally, if I forget to type one eighth,

I’m probably going to accidentally use it for the next position.

So I’m just going to type everything one at a time.

So let’s see, we have one, two, three, four, five, one, two, three, four.

So I got to do one more plus one 32nd and then multiply by the bits.

So say like, you know, one times that and then one times that and then zero times that

to basically, you know, cancel it out.

And then one times that and then one times that.

plug it all into the calculator

let’s see if I got that right

0.84375

so that’s how you convert

back from binary to decimal

pretty easy and then also

of course when you’re practicing this you want to try

with a bunch of different random numbers to start off with

you just want to be

careful again this process

could take forever if you have like

you know the wrong number that you

start with but I guess at least

at least when we’re converting from binary to decimal it’s going to end up resolving to something

uh it won’t necessarily be something that you can’t represent but you know if you start

up with a random number in decimal there’s a chance maybe it’s not going to work with binary

okay well you have to give up and call it a precision loss okay so then now let’s uh let’s

ask what if we had a complex number because we know how to do this now with just the fractional

now with just the fractional part but what if we had a number that was um a little bit more

difficult let’s say we have wait a minute you know for you know for 37 5.

oh i think i just accidentally did a totally different number than i wanted to on my plan

luckily i got the right answer okay

Anyway, what if we had a more complicated number?

Let’s see, 804, 6875.

Okay, so 804, 6875, but with a 45 in front of that.

Remember we said before that this is the whole part

and this is the fractional part,

and you just wanna do them separately

and then combine them afterwards.

So the whole part, let’s see, what is that gonna be?

I’m just gonna say that this is not a video

for whole number binary conversion.

This is just dealing with fractions.

just dealing with fractions. Find my other videos if you want to know how to convert the whole part,

but I’m going to say that 45 is just this number in binary. And you can double check real fast.

You can say 1 plus, here let’s do it again, let’s do it just to be sure. 1 plus not a 2 because

there’s a 0 there, and then we’ll say 4 plus 8 plus not a 16 because there’s a 0 there, and then

plus 32. Add that together, that’s 45. So the whole number part is pretty easy if you already know how

number part is pretty easy if you already know how binary conversion but now let’s convert point uh

zero eight zero point eight zero four whoops screenshot no thank you zero point eight oh four

six eight seven five so i’m gonna have to do this from scratch since this is a different number than

i just worked with we’ll do that multiplied by two and it’s going to be this number

is that really not the same number?

Yeah, I guess I really just did a different number.

Okay, so that means we’re going to have a 1 in the binary position

and the remaining fractional part is just going to be this.

Whoops, zero point that.

So then we take that number and bring it down.

Multiply it by 2.

Whoops, not supposed to actually bring that part down.

We’ll bring it into the calculator.

We’ll multiply it by 2.

actually let me get that again and subtract one just to double check myself it’s always good to

double check yourself then we’ll multiply this by two and then the number is going to be point

1.28 so we have that and then since it’s either equal to or greater than one it’s going to be

you know a one in the binary position so 0.21875 is going to be the remainder there

so I’m going to do minus 1 and then times 2 to make sure the calculator agrees with me whoops

21875 okay then I’ll do a multiply by 2 to get the next number 4 3 7 5

and that’s not equal to or greater than 1 so we’ll put a 0 there and we won’t subtract anything

so it’s just going to be 0.4375 again then we’ll multiply that by 2 to get the next number

times two it’s going to be 0.875 so 0.875 again this is not one or greater so we have zero in

the binary position and we don’t subtract anything 0.875 multiply by two again times two so it’s

going to be 1.75 1.75 and then of course we’ll have a one in the binary position and the leftover

0.75 so let me just go back to the calculator and I’ll say minus 1 times 2 it’ll give us 1.5

so 1.5 over here means we’ll have a 1 in the binary position because it was equal to or greater

than 1 the leftover is going to be 0.5 now you know we’re about to finish because 0.5 times 2

is just going to be 1.0 which will give us a 1 for the binary part and then the remainder is going

remainder is going to be 0.0 and then you know there’s no need to multiply 0 by 2 because it is

forever going to just be zeros uh maybe i’ll just write it out one more time just so you know 000

right remember that so that means of course the zeros are on the right side of the fractional

part and on the left side is going to be 0.110011

1100111 and then now we just have to combine those two numbers so maybe just I’ll put something

here indicating that this is the conversion of just that number like that now we’ll combine

both of those parts right so 45 was this so I’ll say maybe therefore this big number right here

combine this number for 45 and then I’ll just put a decimal point and then I’ll put the fractional

part on the right side and then let me just double check my work real fast it should be

10110111 wait wait what no no 101101 and then 1100111 okay so that’s it we’ve converted

converted a complicated decimal number into binary.

And we can do it in the reverse, just using the same thing.

You know, step one, convert this number into a whole number of decimal.

And then step two, convert this number into a whole number,

sorry, a just only fractional number for decimal

by just getting the one half plus one fourth and so forth.

put them around a decimal point just for practice okay I’ll go ahead and do it

some of you are probably like why won’t you do it I’ll do it okay so just only

looking at the fractional part because that this is not a video to convert

whole numbers in binary and decimal but just to convert the fractional part only

I’m gonna do let’s see say whoops whoops whoops whoops whoops whoops maybe I need

Okay, so starting with just this one right here,

it’s going to be 1 half plus 1 fourth plus not 1 eighth, not 1 16th, a 32.

1 32 plus 1 over 64 plus 1 over 128.

0.8046875.

So it looks like we succeeded.

Okay, so now we know how to convert

a decimal number with a fraction

into a binary number with a fraction.

And we also know how to convert

a binary number with a fraction

to a decimal number with a fraction.

That feels like a long video.

Let’s see what it is after I cut this.

Thank you so much for watching.

I hope you learned a little bit of stuff

and you had a little bit of fun.

I will see you in the next video.

grow this community so we’ll be able to do more videos, longer videos, better videos,

or just I’ll be able to keep making videos in general. So please do me a kindness and subscribe.

You know, sometimes I’m sleeping in the middle of the night and I just wake up because I know

somebody subscribed or followed. It just wakes me up and I get filled with joy. That’s exactly what

happens every single time. So you could do it as a nice favor to me or you could troll me if you

want to just wake me up in the middle of the night, just subscribe and then I’ll just wake up.

I promise that’s what will happen.

Also, if you look at the middle of the screen right now, you should see a QR code which you can scan in order to go to the website,

which I think is also named somewhere at the bottom of this video.

And it’ll take you to my main website where you can just kind of like see all the videos I published and

the services and tutorials and things that I offer and all that good stuff.

And if you have a suggestion for

or just future videos that you want to see, please leave a comment. Or if you just want to say,

hey, what’s up? What’s going on? You know, just send me a comment, whatever. I also wake up for

those in the middle of the night. I get, I wake up in a cold sweat and I’m like,

it would really, it really mean the world to me. I would really appreciate it. So again,

thank you so much for watching this video and enjoy the cool music as, as I fade into the

darkness, which is coming for us all.

Thank you.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply