*PLEASE READ THIS COMMENT IN ITS ENTIRETY FOR MORE INFO AND ERRORS IN THE VIDEO* 1. There is an edge case called "Denormal Numbers" that has not been accounted for in this video. Thanks to @PRANAnomaly for sharing! I have made a new video to discuss this concept: ruclips.net/video/b2FgF2sUoS8/видео.html Another set of special cases, namely Infinity and NaN, are also not covered in this video. For more details, please watch this other video I made: ruclips.net/video/D7LRjJeRKJw/видео.html 2. ERRATA: At 2:20, note that the number on the right should either be written as 1/2 or 2^-1, but not 2^(1/2)! Thanks 業夝王 for bringing this to my attention! 3. ERRATA: At 15:47, note that the bits from the decimal portion were read off incorrectly. Thank you to spinakker for sharing! This is the version corrected by them: i.imgur.com/ufOeklR.png
Hello and thank you for your comment! Thanks for the heads up! I found that the pinned comment on quite a few of my videos had gotten unpinned somehow. I put them back whenever I come across them.
Hello and thank you for your comment! When working with floating point numbers, floating point imprecision may cause the number to be different from what you expect - In this case here, the variable a might get stored as 3.400001 or something along those lines. Because of this, it doesn't exactly match the equality comparison, and falls into the else block. It's best to test floating point numbers in a range rather than with an equality operator like this.
Omg do you have any idea how many videos I have watched, reread my CPE textbook to try to figure out why we add 1 to the mantissa. My textbook literally says, there's a one but it can be omitted and that bothered me so much that I didn't know. But now it makes sense, technically there is a 2 to the power of zero which is where the 1 comes from. Thank you!!!!!!!
You definitely earned this sub. This was an amazingly edited video and the information was thoroughly explained, much appreciated! If you want to find the range of this representation is it take all 1s for all the exponent bits for the largest possible exponent, take 1s for all the mantissa bits, add one to the mantissa and then complete the calculation from negative sign to positive sign?
Hello and thank you very much for your comment and support! If you're looking for the smallest possible number (ie. a negative number) all the way up to the largest positive number, then yes - Just make the largest possible exponent and mantissa with both positive and negative signs and you'll get both. If you want to find the smallest positive number though, that's a bit harder. For that you'll need to look into Denormal numbers, which I did not cover in this video. A denormal number allows you to get an even smaller exponent than the exponent actually allows, by using zeroes in the mantissa. For more: ruclips.net/video/b2FgF2sUoS8/видео.html
Thank you for making this video. You literally just helped me pass an exam i couldn't have studied on time for. You are the best. Keep up the good work.
I have been struggling with this chapter for days and you just explained it in 15 minutes ?? I wish I had found this video sooner. Thank you so so much, this was extremely helpful :D
Heh, thank you very much! Though to be honest, college forces you to do a lot of things that are necessary and yet would be things you wouldn't care about learning on your own. Still worth it!
Hello and thank you very much for your comment! Glad to be of help =) If you have anything you'd like me to clarify, feel free to let me know in a comment and I'll do what I can to help you!
Hello and thank you very much for your comment! Yeah, this particular video was months in the making, heh. Honestly, quite relieved it's up. Glad you liked it =)
14.25 -' if it was a zero we could stop it at a different place and express with a different exponent' ? What different place and what different exponent. I have used this video to code the floating point in VBA.It works with everything other than say 0.5. Very good video !
Hello and thank you for your comment! What I mean is, if you don't have the rule that the mantissa starts with 1, then all of the below are valid representations of 0.25: 0.25 × 2^1 0.5 × 2^-1 1 × 2^-2 2 × 2^-3 So to make the numbers consistent, the rules say the mantissa has an implied "1." in front.
Oh now I understand why we have to subtract 127: cause the exponent is 8 bit, so the max of it is 0-255. Inorder to represent smaller number(by multiply it with 2^-5 for ex), we have to represent the exponent in negative number => Split 255 in half = 127. And a second problem is why 2^ but not 10^ because by using base 2, we can convert bit to float and float to bit 😁
Hello and thank you for your comment! I would say simply that we use Base 2 because computers represent information in binary. Even when it's in bits (base 2), it already _is_ a floating point number,
Hey man, great video! Could you explain why the exponent is represented with an offset and not another representation such as 2-complement? Thanks for the video!
Hello and thank you for your comment! The short answer would be "That is how it's designed", but naturally I was curious also as to why it was designed this way. Some people suggest that this helps with comparing two numbers - With the offset representation you could simply compare the bit strings of two floating point numbers as if they were integers and the answer would be correct. I wasn't able to find an official source to say that this is the reason why it was designed like that but it does seem to make a lot of sense. Some sources where this is discussed: employees.oneonta.edu/zhangs/csci201/IEEE%20Floating%20Point%20Format.htm stackoverflow.com/questions/2835278/what-is-a-bias-value-of-floating-point-numbers
Nice explanation/narration. Nice animations and graphical illustrations. Clear and concise while being thorough enough. The light reflections in your glasses are somewhat distracting tho...
Hello and thank you very much for your comment! The reflections are hard to avoid when you want to light someone face-on, unfortunately! I've been experimenting with other placements to see the effect.
Hey bro, i have an exam tomorrow, which includes this theme could you give me an answer to my question, which is: How do i know, when a number is positive, and when not? I'd be more than thankful to know.
Hello and thank you for your comment! To do that, look at the most significant bit (the one on the left) - That's the sign bit. If it's 1, the number is negative, if it's 0, the number is positive. All the best for your exam!
My question is how large is the range of values able to be represented with this system, and what solutions/alternatives are used to represent larger or smaller numbers outside the range. Obviously floating point rounding will make some stuff imprecise, but I mean what is the largest and smallest absolute value for this?
Hello and thank you for your comment! To derive the largest and possible floating point values, the technique is to go for the largest possible exponent and mantissa. Then, flip the sign - The positive version is the largest possible value and the negative version is the smallest. Usually we also want to consider the smallest magnitude number (ie. The smallest positive number). For that, you'll need to go for the smallest denormal number (in which all exponent bits are zero), and only the least significant bit of the mantissa is 1. These have been worked out for 32-bit floats here but you technically do this for any bit length: stackoverflow.com/questions/32193791/single-precision-floating-point-format-range The simple solution to getting a larger range is to either use more bits, or to simply not use floats at all. Using strings or BigDecimal strategies are possible alternatives.
I'm surprised that the sign bit just exists on its own and neither the exponent nor mantissa is in 2's compliment. I know if was writing the IEEEC floating point standard, at least the mantissa would be in 2's compliment just to keep parity with the way signed integers are stored. IDK if they have a good logic for not storing it in 2's compliment.
Hello and thank you for your comment! This is an interesting thought. Technically, a 2's complement number still has a "sign bit", just that the behavior of the rest of the bits are also different, so the technique here is closer to "sign and magnitude". One thing I can't comment on is whether this particular arrangement of bits has anything to do with how floating point operations can be implemented in hardware - Perhaps some operations are easier, that's why it's done this way.
I think this is the best explanation on the topic. However, still cannot grasp why the number on the exponent has to be inserted exponent + 127. Why cant we deal with negative numbers using normal 2 complement?
Hello and thank you for your comment! That's an interesting question - Unfortunately the basic answer would just be "that's how it was designed". But I _have_ found some interesting debates about the pros and cons of different negative number representations. This may be of interest to you: cs.stackexchange.com/questions/6048/why-floating-point-representation-uses-a-sign-bit-instead-of-2s-complement-to-i
I don't really understand this part at 7:00 Why can't they just represent the Exponent by just writing 00000100? Why do we need to make it as an offset
Hello and thank you for your comment! The exponent can be a positive number (to represent large numbers), or a negative number (to represent small numbers). Having an offset exponent allows you to get negative exponents after doing the calculation, which is why it exists. This offset method isn't the only way of representing negative numbers in computer science, but is the strategy adopted for floating point numbers.
whats the point of having an offset in exponent, why just keep the signed bit representation?... is there more benefit for having an offset rather than using signed? also sry my english is bad
Hello and thank you for your comment! I suspect one of the reasons is the lower computational overhead, and the fact that it allows you to compare floating point numbers in the same way you could compare integers.
Been working in CS for years, this is the first time binary number conversion has made any sense. Unless you're my boss in which case I am joking and I have always known my basics.
Hello and thank you for your comment! Glad to be of help, and don't worry, if I _were_ your boss, I wouldn't think that a low level understanding of numerical representation is really useful for most day-to-day programming scenarios.
Hello and thank you for your comment! Yes, the process is the same. Just check the sign bit and see if it's 1. If it is, negate the value you've calculated.
Hello and thank you for your comment! Since the exponent is 8 bits and we want it offset, a reasonable value will be to go halfway in between the 8-bit space so that we have an equal number of positive and negative numbers. That narrows it down to 127 and 128. But as to why 127 has been chosen, I haven't been able to find an official reasoning for it. The best explanation I've found so far is that this makes it easy to compare two floating point numbers with each other using integer representations, and still be able to tell which is larger or smaller. But I'm not sure if there's any proof to say this is really the reason why IEEE chose excess-127 representation for the exponent. Some sources where this is discussed: employees.oneonta.edu/zhangs/csci201/IEEE%20Floating%20Point%20Format.htm stackoverflow.com/questions/2835278/what-is-a-bias-value-of-floating-point-numbers
Hello and thank you for your comment! It depends on what you mean by "these kinda topics" - Floating point numbers is at the intersection of a few broad categories, and you could be referring to any of them. Alternatively you may also want to sort my channel by most popular. Barring a few product reviews which might be less interesting to you, I think you'll find most of the others to at least be relevant.
Hello and thank you for your comment! Let me try to walk through the entire process. The two bits that are 1 are in the 2^-4 and 2^-7 positions respectively, so they come out to (1/16) and (1/128). To figure out what value they represent, you have to add these numbers together. So we're trying to do 1/16 + 1/128 = 8/128 + 1/128 = 9/128.
Hello and thank you for your comment! The bits should be read .001, ie. The video is wrong. You can refer to the pinned comment for further clarification.
well, finally i could work out my self after a very long time. because i couldn't understand way i always got incorrect result on my end., but i rather got the Big-endian correct, and when i tryed to swap the bytes i got a huge number. Turns out after a few hour, the HeX editor was telling in E notation... so my answer was correct for a long time, because i didn't see the "e"
@@NERDfirst Yes indeed, i wrote a function 2 days ago that turned 8 bytes to float64 manually.., which then turned into a wall of text in code ...oh dear..., but anyway, the only weird thing, 4 decimal back, it rounded up. i guess that's a floating point quirk on my cpu or compiler
Hello and thank you for your comment! To be fair, computers don't actually go out of their way to round off floating point numbers unless you specifically tell them to. In the broadest sense, if numbers seem to be rounded off to you, it may be caused by imprecisions in representing the number.
IEEE floating point numbers use an implicit 1 to start off the mantissa, because by definition, the mantissa can’t start with 0, and the only other digit in binary is 1. However, when the exponent is the minimum (stored as 0), it’s treated as if the exponent is 1 greater than that, and the mantissa starts with 0 instead. This is called denormal or subnormal numbers, and it makes numbers very close to 0 representable.
Hello and thank you for your comment! I'm afraid I don't understand your question. Please review the video starting from 9:55, and let me know if there's any specific step I can explain better.
2:20 I'm confused here. I fairly remember that we were taught; 2^(1/2) = "Square root of 2" (which is not 0.5) But if 2^(-1) means "1 upon 2^1", then it's 1/2 = 0.5 as you are saying. I assume it's a screen error. Am I right? Or maybe I'm not understanding your tutorial property. Is that so ? 🤔
@@NERDfirst Hi dear sir, I learnt a lot from your video!! Things I never understood before, are now very clear. I'm an audio producer, and I was curious to know why higher wav bit-depth(s) have the prefix "floating point". Thank you so much for this explanation, all your time spent on preparing these, and for your very quick reply to the initial comment above. (I asked it just bec I have weak confidence in maths, and I wasn't sure whether that's actually a typo, or perhaps something which I don't understand.)
Ohh nvm I kind of understand. The exponent is unsigned, so an exponent like -120 can't be expressed. So, you offset it by 127 to make it positive. That means the lowest possible exponent is -127. Am I correct?
Hello and thank you for your comment! Yep that's basically it. We want the possibility of representing a negative exponent while not wanting to use a 1s or 2s complement signed number. So we offset the number instead. Do note that for floating point numbers, an exponent of -127 has a special meaning. More on this here: ruclips.net/video/b2FgF2sUoS8/видео.html
You said if the exponent part is zero then the exponent is -127, but that’s not what I get when I put in all zeros for the exponent in an online calculator. I’m confused... (7:45)
Hello and thank you for your comment! Did you forget to change all the exponent bits? Remember the last bit of the exponent "cuts into" the second byte.
@@NERDfirst No, it says the exponent is -126 on all the calculators I've found online. Here's an example: www.h-schmidt.net/FloatConverter/IEEE754.html
Thanks for sharing! This seems like a special edge case called "denormalized numbers" where the exponent is used differently from the usual rules. I'll see how I can add on to this video. Source: en.wikipedia.org/wiki/IEEE_754-1985#Denormalized_numbers
@@poorman-trending I have updated my simulation resources.nerdfirst.net/float so it reflects the correct behavior. I'll make another video to cover the concept of denormal numbers.
Hello and thank you for your comment! I'm not familiar with the exact math to calculate these values. You may want to refer to wikipedia here for more: en.wikipedia.org/wiki/Floating-point_arithmetic#Range_of_floating-point_numbers
One question: If exponent part is unsigned and we are substracting 127 from it, why don't we just represent exponent as signed intereger such as most significant bit is sign and rest is value ?
Hello and thank you for your comment! The technique used for the exponent _is_ one of the standard signed number techniques called "excess-K" or "offset binary". I suppose you mean why we don't use something like two's complement, but I believe it's ultimately a design decision. Maybe there are some concerns for performance as well.
Using an offset for the exponent makes sorting floating point numbers easy. That way, the bitstring for exponent 127 will be smaller than for exponent 128.
I'm 72. Real powerful presentation, and your "Floating Point Explorer" calculator gives a chance to verify my understanding. Thank you. 2021 10 04 (as 2 years after publishing)
THANK YOU. The way floating point numbers were explained in my textbook made absolutely no sense. This was easy to follow and actually helped me get my head around the concept. You're the best!
You're welcome! Very happy to be of help =) For a more complete understanding, you might want to watch the follow up videos about Denormal numbers, and do take note of the errata in the comments as well.
I appreciate so much having found this video, is not only greatly explained. But the page with the Floating point explorer is just beautiful. Thank you!
Hello and thank you very much for your comment! Yes indeed! Must've spaced out there. It's either 1/2 or 2^-1 but not both at the same time. I'll add an errata notice. Thanks!
Hello and thank you for your comment! This video covers a very small subset of the IEEE 754 standard. The standard also includes things like rounding rules, infinity, NaN (not a number) etc, which I have all left out. And of course, this is just the 32-bit format. According to wikipedia the standard specifies 8 formats with different bit lengths. So yeah, I think this is a good starting point, but not a substitute for actual material if you want to know the standard well!
3 года назад
thank you very much, great explanation! :-) Cheers from Czech republic.
Hello and thank you for your comment! Well spotted! I'll go ahead and add a note to the pinned comment. I'll link to your picture and give you credit. Thanks!
Fantastic video! Very interesting stuff. One question though, why subtract 127 in the exponent section? What led to that being the number to offset by? I'm guessing it's somehow related to 2^7 (128) but why is it 1 less than 128 and not just the entire thing?
Hello and thank you for your comment! This is a very interesting point. Of course, we know it's got to be between 127 and 128, since that's halfway in between the given 8-bit space, and we ideally want to have an equal number of positive and negative numbers. But as to why 127 has been chosen, I haven't been able to find an official reasoning for it. The best explanation I've found so far is that this makes it easy to compare two floating point numbers with each other using integer representations, and still be able to tell which is larger or smaller. But I'm not sure if there's any proof to say this is really the reason why IEEE chose excess-127 representation for the exponent. Some sources where this is discussed: employees.oneonta.edu/zhangs/csci201/IEEE%20Floating%20Point%20Format.htm stackoverflow.com/questions/2835278/what-is-a-bias-value-of-floating-point-numbers
@@NERDfirst Thank you so much for the reply, even several years after the making of this video! Your comment helped me understand a bit more about the way floating point numbers work, but I'm still not at the point where I know what integer representations are and all that. Much less whatever was being discussed on that stack overflow thread hahaha. Looking forward to be able to understand all that one day though! Your sheer knowledge and readiness to share it really shows your passion for the subject :) I'm really glad we have people like you to help us noobs out, you're really doing a service to the world!
No problem! All I want to do is to make learning more accessible, so I'm really glad I could be of help! "Integer representations" just refer to reading off the string of bits as a whole number, instead of breaking up the bits into sign, exponent and mantissa parts. So even if we just treated it (wrongly!) as a whole number, comparison operations would still make sense and give correct answers. If you're interested to find out more about bits I have another video here that you might like to look over: ruclips.net/video/4Qls3vRA_F4/видео.html Again, thank you very much for your nice comment. Makes it all worth it =)
@@NERDfirst I can't believe how helpful that was! I can literally feel my brain expanding by the minute hahahaha. No matter how many times I thank you, it probably won't be enough, so here's a few cookies instead: 🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪 enjoy! While you enjoy munching on them, I'm gonna go do myself a favour and check out your other stuff ;P see you!
Thank you very much! Yes, please do feel free to check out the other videos and if you have any other thoughts or questions, don't hesitate to comment on those too =)
After 2 -3 videos I found this video and it cleared all my doubts and I just want to tell you that I am in love with your explanation .Loveeeeeeee Youuuuuu bro
Hello and thank you for your comment! For each "layer", the answer comes from the previous number multiplied by two. For the final "layer", 0.5 × 2 gives 1. Since it is greater than or equal to one, we subtract one. This leave us with zero.
*PLEASE READ THIS COMMENT IN ITS ENTIRETY FOR MORE INFO AND ERRORS IN THE VIDEO*
1. There is an edge case called "Denormal Numbers" that has not been accounted for in this video. Thanks to @PRANAnomaly for sharing! I have made a new video to discuss this concept: ruclips.net/video/b2FgF2sUoS8/видео.html
Another set of special cases, namely Infinity and NaN, are also not covered in this video. For more details, please watch this other video I made: ruclips.net/video/D7LRjJeRKJw/видео.html
2. ERRATA: At 2:20, note that the number on the right should either be written as 1/2 or 2^-1, but not 2^(1/2)! Thanks 業夝王 for bringing this to my attention!
3. ERRATA: At 15:47, note that the bits from the decimal portion were read off incorrectly. Thank you to spinakker for sharing! This is the version corrected by them: i.imgur.com/ufOeklR.png
Somehow this comment is not pinnted to the top...You can add it to your subtitles.
Hello and thank you for your comment! Thanks for the heads up! I found that the pinned comment on quite a few of my videos had gotten unpinned somehow. I put them back whenever I come across them.
@@NERDfirst Thanks for the reply. Your videos help me a lot!
This was so far the most helpful video on floating-point representation I've seen. I'm surprised it didn't get more views. Thanks man!
Hello and thank you very much for your comment! Glad to be of help =)
Thanks, bro! This is SOOOOOO appreciated. I literally have a test on this stuff in about 9 hours.
Hello and thank you for your comment! All the best for your test =)
How did u do
@@okboing Super late, but I passed with a B+.
@@ladell5101YES!
Thank you! I finally understand this after avoiding the subject for an entire semester..
Hello and thank you for your comment! Very happy to be of help =) Glad you got over that hurdle!
thanks for putting in so much hard work in creating these videos . amazing explanation on floats .
Hello and thank you very much for your comment! Glad you found the video useful =)
It's much more clear for me how floating point representation works. Thanks!
You're welcome! Very happy to be of help =)
Damn, so clearly explained, man when I read in books I didn't understand at all 🤣🤣🤣
Hello and thank you for your comment! Glad to be of help =)
Please, make a video on reason of output of -------
float a=3.4;
if(a==3.4) printf("hello");
else printf("hii");
Hello and thank you for your comment! When working with floating point numbers, floating point imprecision may cause the number to be different from what you expect - In this case here, the variable a might get stored as 3.400001 or something along those lines. Because of this, it doesn't exactly match the equality comparison, and falls into the else block.
It's best to test floating point numbers in a range rather than with an equality operator like this.
Omg do you have any idea how many videos I have watched, reread my CPE textbook to try to figure out why we add 1 to the mantissa. My textbook literally says, there's a one but it can be omitted and that bothered me so much that I didn't know. But now it makes sense, technically there is a 2 to the power of zero which is where the 1 comes from. Thank you!!!!!!!
Hello and thank you very much for your comment! Glad to be of help =)
You definitely earned this sub. This was an amazingly edited video and the information was thoroughly explained, much appreciated! If you want to find the range of this representation is it take all 1s for all the exponent bits for the largest possible exponent, take 1s for all the mantissa bits, add one to the mantissa and then complete the calculation from negative sign to positive sign?
Hello and thank you very much for your comment and support!
If you're looking for the smallest possible number (ie. a negative number) all the way up to the largest positive number, then yes - Just make the largest possible exponent and mantissa with both positive and negative signs and you'll get both.
If you want to find the smallest positive number though, that's a bit harder. For that you'll need to look into Denormal numbers, which I did not cover in this video. A denormal number allows you to get an even smaller exponent than the exponent actually allows, by using zeroes in the mantissa. For more: ruclips.net/video/b2FgF2sUoS8/видео.html
this is way better than my module! finally get to understand :)
Hello and thank you for your comment! Glad you liked the video =)
Sir you have a natural talent to teach, thank you sooo much !!
You're welcome! Very happy to be of help =)
Thank you for making this video. You literally just helped me pass an exam i couldn't have studied on time for. You are the best. Keep up the good work.
You're welcome! Very happy to be of help =)
I dont care who you are, where you're from. I just want to say I fking love you.
Hello and thank you very much for your comment! Glad you found the video helpful =)
I have been struggling with this chapter for days and you just explained it in 15 minutes ?? I wish I had found this video sooner. Thank you so so much, this was extremely helpful :D
You're welcome! Very happy to be of help =)
very good explanation.
Hello and thank you for your comment! Glad you liked the video =)
1+1/16+1/128 = 137/128? Can you explain this please.
Hello and thank you for your comment!
1 + 1/16 + 1/128
= (128/128) + (8/128) + (1/128)
= (128+8+1)/128
= 137/128
Why am I even paying tuition?
Heh, thank you very much! Though to be honest, college forces you to do a lot of things that are necessary and yet would be things you wouldn't care about learning on your own. Still worth it!
Very good video. Even though I didn't fully understand the process, it's still much easier to wrap my head around this concept overall.
Thank you 🙏🙏
Hello and thank you very much for your comment! Glad to be of help =) If you have anything you'd like me to clarify, feel free to let me know in a comment and I'll do what I can to help you!
I'm very sure it wasn't easy to put all of these great work together. I thank you for that.
Hello and thank you very much for your comment! Yeah, this particular video was months in the making, heh. Honestly, quite relieved it's up. Glad you liked it =)
nice
video
very good
Hello and thank you for your comment! Glad you liked the video :)
Legendary guy!!!!
Hello and thank you very much for your comment! Glad you liked the video =)
14.25 -' if it was a zero we could stop it at a different place and express with a different exponent' ? What different place and what different exponent. I have used this video to code the floating point in VBA.It works with everything other than say 0.5. Very good video !
Hello and thank you for your comment! What I mean is, if you don't have the rule that the mantissa starts with 1, then all of the below are valid representations of 0.25:
0.25 × 2^1
0.5 × 2^-1
1 × 2^-2
2 × 2^-3
So to make the numbers consistent, the rules say the mantissa has an implied "1." in front.
Oh now I understand why we have to subtract 127: cause the exponent is 8 bit, so the max of it is 0-255. Inorder to represent smaller number(by multiply it with 2^-5 for ex), we have to represent the exponent in negative number => Split 255 in half = 127. And a second problem is why 2^ but not 10^ because by using base 2, we can convert bit to float and float to bit 😁
Hello and thank you for your comment! I would say simply that we use Base 2 because computers represent information in binary. Even when it's in bits (base 2), it already _is_ a floating point number,
this was freakingggg helpful...
I don't why you have very less subs
I believe you will reach to millions of subs Soo fast
Hello and thank you for your comment! I don't do marketing of any kind, so that's one reason why!
Hey man, great video!
Could you explain why the exponent is represented with an offset and not another representation such as 2-complement?
Thanks for the video!
Hello and thank you for your comment! The short answer would be "That is how it's designed", but naturally I was curious also as to why it was designed this way.
Some people suggest that this helps with comparing two numbers - With the offset representation you could simply compare the bit strings of two floating point numbers as if they were integers and the answer would be correct. I wasn't able to find an official source to say that this is the reason why it was designed like that but it does seem to make a lot of sense.
Some sources where this is discussed:
employees.oneonta.edu/zhangs/csci201/IEEE%20Floating%20Point%20Format.htm
stackoverflow.com/questions/2835278/what-is-a-bias-value-of-floating-point-numbers
you just saved my life. there is no other video explaining this stuff more clearly than you.
Hello and thank you for your comment! Glad to be of help =)
Nice explanation/narration. Nice animations and graphical illustrations. Clear and concise while being thorough enough. The light reflections in your glasses are somewhat distracting tho...
Hello and thank you very much for your comment! The reflections are hard to avoid when you want to light someone face-on, unfortunately! I've been experimenting with other placements to see the effect.
Wow ... I feel like fall in love with floating point numbers... Your video is awsome Thank you :D
You're welcome! Very happy to be of help =)
i see a lot of simplicity in this video , Best WAY to explain stuff , thank you so much buddy !
You're welcome! Very happy to have been of help =)
Hey bro, i have an exam tomorrow, which includes this theme could you give me an answer to my question, which is:
How do i know, when a number is positive, and when not?
I'd be more than thankful to know.
Hello and thank you for your comment! To do that, look at the most significant bit (the one on the left) - That's the sign bit. If it's 1, the number is negative, if it's 0, the number is positive. All the best for your exam!
I was pretty lost when I started to study this topic, but thanks to you it's not a problem anymore. Keep up the good work!
Hello and thank you very much for your comment! Very happy to be of help :)
My question is how large is the range of values able to be represented with this system, and what solutions/alternatives are used to represent larger or smaller numbers outside the range. Obviously floating point rounding will make some stuff imprecise, but I mean what is the largest and smallest absolute value for this?
Hello and thank you for your comment! To derive the largest and possible floating point values, the technique is to go for the largest possible exponent and mantissa. Then, flip the sign - The positive version is the largest possible value and the negative version is the smallest. Usually we also want to consider the smallest magnitude number (ie. The smallest positive number). For that, you'll need to go for the smallest denormal number (in which all exponent bits are zero), and only the least significant bit of the mantissa is 1. These have been worked out for 32-bit floats here but you technically do this for any bit length: stackoverflow.com/questions/32193791/single-precision-floating-point-format-range
The simple solution to getting a larger range is to either use more bits, or to simply not use floats at all. Using strings or BigDecimal strategies are possible alternatives.
Thanks…..I will revisit this video couple of times in order to fully understand floating point.😊
Hello and thank you for your comment! Feel free to do so, and to clarify any doubts in the comments if you need :)
I'm surprised that the sign bit just exists on its own and neither the exponent nor mantissa is in 2's compliment. I know if was writing the IEEEC floating point standard, at least the mantissa would be in 2's compliment just to keep parity with the way signed integers are stored. IDK if they have a good logic for not storing it in 2's compliment.
Hello and thank you for your comment! This is an interesting thought. Technically, a 2's complement number still has a "sign bit", just that the behavior of the rest of the bits are also different, so the technique here is closer to "sign and magnitude".
One thing I can't comment on is whether this particular arrangement of bits has anything to do with how floating point operations can be implemented in hardware - Perhaps some operations are easier, that's why it's done this way.
I think this is the best explanation on the topic. However, still cannot grasp why the number on the exponent has to be inserted exponent + 127. Why cant we deal with negative numbers using normal 2 complement?
Hello and thank you for your comment! That's an interesting question - Unfortunately the basic answer would just be "that's how it was designed". But I _have_ found some interesting debates about the pros and cons of different negative number representations. This may be of interest to you: cs.stackexchange.com/questions/6048/why-floating-point-representation-uses-a-sign-bit-instead-of-2s-complement-to-i
I don't really understand this part at 7:00 Why can't they just represent the Exponent by just writing 00000100? Why do we need to make it as an offset
Hello and thank you for your comment! The exponent can be a positive number (to represent large numbers), or a negative number (to represent small numbers). Having an offset exponent allows you to get negative exponents after doing the calculation, which is why it exists. This offset method isn't the only way of representing negative numbers in computer science, but is the strategy adopted for floating point numbers.
whats the point of having an offset in exponent, why just keep the signed bit representation?...
is there more benefit for having an offset rather than using signed?
also sry my english is bad
Hello and thank you for your comment! I suspect one of the reasons is the lower computational overhead, and the fact that it allows you to compare floating point numbers in the same way you could compare integers.
Been working in CS for years, this is the first time binary number conversion has made any sense. Unless you're my boss in which case I am joking and I have always known my basics.
Hello and thank you for your comment! Glad to be of help, and don't worry, if I _were_ your boss, I wouldn't think that a low level understanding of numerical representation is really useful for most day-to-day programming scenarios.
Will this process be the same if the decimal number is negative like (-17.125)?
Hello and thank you for your comment! Yes, the process is the same. Just check the sign bit and see if it's 1. If it is, negate the value you've calculated.
Why the offset number is particularly choosed as 127 ?
Hello and thank you for your comment! Since the exponent is 8 bits and we want it offset, a reasonable value will be to go halfway in between the 8-bit space so that we have an equal number of positive and negative numbers. That narrows it down to 127 and 128.
But as to why 127 has been chosen, I haven't been able to find an official reasoning for it. The best explanation I've found so far is that this makes it easy to compare two floating point numbers with each other using integer representations, and still be able to tell which is larger or smaller. But I'm not sure if there's any proof to say this is really the reason why IEEE chose excess-127 representation for the exponent.
Some sources where this is discussed:
employees.oneonta.edu/zhangs/csci201/IEEE%20Floating%20Point%20Format.htm
stackoverflow.com/questions/2835278/what-is-a-bias-value-of-floating-point-numbers
Hello,
have you created any playlist regarding these kinda topics ,cause i can't find one in your playlists
Hello and thank you for your comment! It depends on what you mean by "these kinda topics" - Floating point numbers is at the intersection of a few broad categories, and you could be referring to any of them. Alternatively you may also want to sort my channel by most popular. Barring a few product reviews which might be less interesting to you, I think you'll find most of the others to at least be relevant.
Amazing video.
Hello and thank you for your comment! Glad you liked the video =)
Thank you dear Bro. Thant's great. Nice. good job. 🙏
You're welcome! Glad to be of help =)
i am so confused at the @8:15 marker where you have 9/128 (not sure where that came from ) what am i missing
Hello and thank you for your comment! Let me try to walk through the entire process.
The two bits that are 1 are in the 2^-4 and 2^-7 positions respectively, so they come out to (1/16) and (1/128). To figure out what value they represent, you have to add these numbers together.
So we're trying to do 1/16 + 1/128 = 8/128 + 1/128 = 9/128.
thats amazing video finally after 4 days i got some easy and interesting video to learn floating point representation thakuu sir
You're welcome! Very happy to be of help =)
Hi, At 15:49 I think you must write 10001.001 or 10001.100 ???? Thank you dear bro
Hello and thank you for your comment! The bits should be read .001, ie. The video is wrong. You can refer to the pinned comment for further clarification.
I LOVE YOU MAHN 😭😭
well, finally i could work out my self after a very long time. because i couldn't understand way i always got incorrect result on my end., but i rather got the Big-endian correct, and when i tryed to swap the bytes i got a huge number.
Turns out after a few hour, the HeX editor was telling in E notation... so my answer was correct for a long time, because i didn't see the "e"
Hello and thank you for your comment! What's important is that you figured it out =)
@@NERDfirst Yes indeed, i wrote a function 2 days ago that turned 8 bytes to float64 manually.., which then turned into a wall of text in code ...oh dear...,
but anyway, the only weird thing, 4 decimal back, it rounded up.
i guess that's a floating point quirk on my cpu or compiler
This really helps but I'm still not sure how computers round off floating point numbers sometimes and other times they don't:/
Hello and thank you for your comment! To be fair, computers don't actually go out of their way to round off floating point numbers unless you specifically tell them to.
In the broadest sense, if numbers seem to be rounded off to you, it may be caused by imprecisions in representing the number.
Hi,
Can we shift the decimal to the left until no bit is left (e.g., 10001.001= .10001001x2^5) ??????
can we take offset -> 4+128=132??????????????
Hello and thank you for your comment! While that would be a valid representation numerically, it doesn't follow the floating point standard.
IEEE floating point numbers use an implicit 1 to start off the mantissa, because by definition, the mantissa can’t start with 0, and the only other digit in binary is 1.
However, when the exponent is the minimum (stored as 0), it’s treated as if the exponent is 1 greater than that, and the mantissa starts with 0 instead. This is called denormal or subnormal numbers, and it makes numbers very close to 0 representable.
HOW DO WE FIND MANTISSA ON LAST PART I MEAN HOW DO WE CALCULATE IT (15.53)
Hello and thank you for your comment! I'm afraid I don't understand your question. Please review the video starting from 9:55, and let me know if there's any specific step I can explain better.
tysmmm u saved me....ur hardwork is much appreciated.
You're welcome! Very happy to be of help =)
Thank u so much! The textbook was not much help.
You're welcome! Very happy to be of help =)
2:20 I'm confused here. I fairly remember that we were taught; 2^(1/2) = "Square root of 2" (which is not 0.5)
But if 2^(-1) means "1 upon 2^1", then it's 1/2 = 0.5 as you are saying.
I assume it's a screen error. Am I right? Or maybe I'm not understanding your tutorial property. Is that so ? 🤔
Hello and thank you for your comment! Sorry for the confusion, yes that is a typo on my part.
@@NERDfirst Hi dear sir, I learnt a lot from your video!! Things I never understood before, are now very clear.
I'm an audio producer, and I was curious to know why higher wav bit-depth(s) have the prefix "floating point".
Thank you so much for this explanation, all your time spent on preparing these, and for your very quick reply to the initial comment above. (I asked it just bec I have weak confidence in maths, and I wasn't sure whether that's actually a typo, or perhaps something which I don't understand.)
Thank you so much! This is amazing. I still don't understand though, why the exponent has to be offset by 127. Could anyone please explain?
Ohh nvm I kind of understand. The exponent is unsigned, so an exponent like -120 can't be expressed. So, you offset it by 127 to make it positive. That means the lowest possible exponent is -127. Am I correct?
Hello and thank you for your comment! Yep that's basically it. We want the possibility of representing a negative exponent while not wanting to use a 1s or 2s complement signed number. So we offset the number instead.
Do note that for floating point numbers, an exponent of -127 has a special meaning. More on this here: ruclips.net/video/b2FgF2sUoS8/видео.html
king i learnt more from you in 19 minutes than in my university lecture
Hello and thank you for your comment! Glad to be of help =)
i try to watch other videos but only on this one i got it, great explanation, thanks!
You're welcome! Very happy to be of help =)
You said if the exponent part is zero then the exponent is -127, but that’s not what I get when I put in all zeros for the exponent in an online calculator. I’m confused... (7:45)
Hello and thank you for your comment! Did you forget to change all the exponent bits? Remember the last bit of the exponent "cuts into" the second byte.
@@NERDfirst No, it says the exponent is -126 on all the calculators I've found online. Here's an example: www.h-schmidt.net/FloatConverter/IEEE754.html
Thanks for sharing! This seems like a special edge case called "denormalized numbers" where the exponent is used differently from the usual rules. I'll see how I can add on to this video.
Source: en.wikipedia.org/wiki/IEEE_754-1985#Denormalized_numbers
@@poorman-trending I have updated my simulation resources.nerdfirst.net/float so it reflects the correct behavior. I'll make another video to cover the concept of denormal numbers.
what a legend. I really enjoyed the video. Thank you :)
You're welcome! Very happy to be of help =)
Great stuff. I really dont miss going to university with videos like this
Hello and thank you very much for your comment! Glad you liked the video =)
This video is amazing !!!! Thank you so much .. :)
You're welcome! Very happy to be of help =)
W video!
Nice video but what if we have 0 for example 0.75
Hello and thank you for your comment! The procedure is exactly the same. 0.75 is just 3 x 2^-2 (ie 3/4)
Thank you very much this helped me a lot ❤
You're welcome! Glad to be of help =)
Thank you, great explanation!
You're welcome! Very happy to be of help =)
Thank you very clear explanation
You're welcome! Very happy to be of help =)
my lecturer could really learn a thing or two from you
Hello and thank you very much for your comment! Glad you like my work =)
Very thanks to you for your clear information
You're welcome! Very happy to be of help =)
can you tell whats the precision and range here
Hello and thank you for your comment! I'm not familiar with the exact math to calculate these values. You may want to refer to wikipedia here for more: en.wikipedia.org/wiki/Floating-point_arithmetic#Range_of_floating-point_numbers
very helpful thanks
You're welcome! Very happy to be of help =)
Thank you sooooooooo much! I finally got it!
You're welcome! Very happy to be of help =)
One question:
If exponent part is unsigned and we are substracting 127 from it, why don't we just represent exponent as signed intereger such as most significant bit is sign and rest is value ?
Hello and thank you for your comment! The technique used for the exponent _is_ one of the standard signed number techniques called "excess-K" or "offset binary". I suppose you mean why we don't use something like two's complement, but I believe it's ultimately a design decision. Maybe there are some concerns for performance as well.
@@NERDfirst Nice, thank you !
Using an offset for the exponent makes sorting floating point numbers easy. That way, the bitstring for exponent 127 will be smaller than for exponent 128.
this video was amazing, you would be a great professor
Hello and thank you very much for your comment! I do teach in physical classes, so it's good to hear the vote of confidence =)
@@NERDfirst came back to review for my finial exam, your students are very lucky
Amazing explanation ❤
Hello and thank you very much for your comment! Glad you liked the video =)
I'm 72. Real powerful presentation, and your "Floating Point Explorer" calculator gives a chance to verify my understanding. Thank you. 2021 10 04 (as 2 years after publishing)
Hello and thank you very much for your comment! Very happy to be of help =)
2.22`: it is not 2^1/2 but just 1/2, or 2^-1
Hello and thank you for your comment! Yes, this has been noted by another commenter, please refer to the top comment for more information and errata.
You are a life saver! Subbed!
Hello and thank you for your comment! Happy to be of help =)
Your channel deserve more subscribers
THANK YOU. The way floating point numbers were explained in my textbook made absolutely no sense. This was easy to follow and actually helped me get my head around the concept. You're the best!
You're welcome! Very happy to be of help =) For a more complete understanding, you might want to watch the follow up videos about Denormal numbers, and do take note of the errata in the comments as well.
I appreciate so much having found this video, is not only greatly explained. But the page with the Floating point explorer is just beautiful. Thank you!
You're welcome! Very happy to be of help =)
your video is perfect! but I think here is a mistake at 2:20, it should be 2^1+2^-1 not 2^1+2^1/2
Hello and thank you very much for your comment! Yes indeed! Must've spaced out there. It's either 1/2 or 2^-1 but not both at the same time. I'll add an errata notice. Thanks!
awesome description mate
Hello and thank you for your comment! Glad you liked the video =)
Just curious...does your floating point representation fit the IEEE 754 floating-point standard?
Hello and thank you for your comment! This video covers a very small subset of the IEEE 754 standard. The standard also includes things like rounding rules, infinity, NaN (not a number) etc, which I have all left out. And of course, this is just the 32-bit format. According to wikipedia the standard specifies 8 formats with different bit lengths. So yeah, I think this is a good starting point, but not a substitute for actual material if you want to know the standard well!
thank you very much, great explanation! :-) Cheers from Czech republic.
You're welcome! Very happy to be of help =)
Absolutely excellent video. The website you created is a fantastic learning companion to the concept as well. Thank you!
You're welcome! Very happy to be of help :)
I think there might be a mistake around 15:47:
i.imgur.com/ufOeklR.png
Your final string is correct so this must be a type. Still a great video!
Hello and thank you for your comment! Well spotted! I'll go ahead and add a note to the pinned comment. I'll link to your picture and give you credit. Thanks!
My gratitude... is endless.
You're welcome! Glad to be of help =)
Fantastic video! Very interesting stuff.
One question though, why subtract 127 in the exponent section? What led to that being the number to offset by? I'm guessing it's somehow related to 2^7 (128) but why is it 1 less than 128 and not just the entire thing?
Hello and thank you for your comment! This is a very interesting point. Of course, we know it's got to be between 127 and 128, since that's halfway in between the given 8-bit space, and we ideally want to have an equal number of positive and negative numbers.
But as to why 127 has been chosen, I haven't been able to find an official reasoning for it. The best explanation I've found so far is that this makes it easy to compare two floating point numbers with each other using integer representations, and still be able to tell which is larger or smaller. But I'm not sure if there's any proof to say this is really the reason why IEEE chose excess-127 representation for the exponent.
Some sources where this is discussed:
employees.oneonta.edu/zhangs/csci201/IEEE%20Floating%20Point%20Format.htm
stackoverflow.com/questions/2835278/what-is-a-bias-value-of-floating-point-numbers
@@NERDfirst Thank you so much for the reply, even several years after the making of this video! Your comment helped me understand a bit more about the way floating point numbers work, but I'm still not at the point where I know what integer representations are and all that. Much less whatever was being discussed on that stack overflow thread hahaha. Looking forward to be able to understand all that one day though!
Your sheer knowledge and readiness to share it really shows your passion for the subject :) I'm really glad we have people like you to help us noobs out, you're really doing a service to the world!
No problem! All I want to do is to make learning more accessible, so I'm really glad I could be of help!
"Integer representations" just refer to reading off the string of bits as a whole number, instead of breaking up the bits into sign, exponent and mantissa parts. So even if we just treated it (wrongly!) as a whole number, comparison operations would still make sense and give correct answers. If you're interested to find out more about bits I have another video here that you might like to look over: ruclips.net/video/4Qls3vRA_F4/видео.html
Again, thank you very much for your nice comment. Makes it all worth it =)
@@NERDfirst I can't believe how helpful that was! I can literally feel my brain expanding by the minute hahahaha. No matter how many times I thank you, it probably won't be enough, so here's a few cookies instead: 🍪🍪🍪🍪🍪🍪🍪🍪🍪🍪 enjoy!
While you enjoy munching on them, I'm gonna go do myself a favour and check out your other stuff ;P see you!
Thank you very much! Yes, please do feel free to check out the other videos and if you have any other thoughts or questions, don't hesitate to comment on those too =)
After 2 -3 videos I found this video and it cleared all my doubts and I just want to tell you that I am in love with your explanation .Loveeeeeeee Youuuuuu bro
Hello and thank you very much for your comment! Very happy to be of help =)
One of the few videos on RUclips regarding floats where IEEE-754 is respected. Good job!
Hello and thank you very much for your comment! Do note that I do make some mistakes, please refer to the pinned comment for more =)
Hi. Great explanation. Quick question. In (11:57) u state one subtract from 0.5 is 0. Not clear. Can u explain again pls?
Hello and thank you for your comment! For each "layer", the answer comes from the previous number multiplied by two. For the final "layer", 0.5 × 2 gives 1. Since it is greater than or equal to one, we subtract one. This leave us with zero.
Thank you sooo much !!!
You're welcome! Happy to be of help =)
Thank you so much.
You're welcome! Glad to be of help =)
amazing explanation
Hello and thank you very much for your comment! Glad you liked the video :)
thank you so much
You're welcome! Happy to be of help :)
loved it. really helped me. It was the only thing I did not know for my exam. It is in 2 hours.
Hello and thank you for your comment! All the best for your exam!
Very clearly explained! Thank you for this video
You're welcome! Very happy to be of help =)
Love your video man !!!
Hello and thank you for your comment! Glad you liked the video =)