IEEE 754: 32 Bit Single Precision Floats

preview_player
Показать описание
This tutorial we'll look at 32 bit floating point bit patterns in detail as well as a method for getting the bit pattern to a 32 bit IEEE 754 float from a decimal number.
Рекомендации по теме
Комментарии
Автор

Your channel is amazing, there is genuinely a lack of tutorials for people doing assembly. Thanks you saved my day.

crunchyleif
Автор

lol I knew I would find how to do this somewhere in YouTube. I don't regret missing that class anymore

EXHellfire
Автор

The bias is 15 for 16 bit floats (like the GPU sometimes uses), 127 for 32 bit floats, 1023 for 64 bit doubles and 16383 for 80 bit extended precision (like our x87 FPU uses). Each of the different sized floats has it's own predefined bias.

I guess they had a choice, the exponent field gives magnitude and the mantissa gives precision, they figured an 8 bit exponent and 23 bit mantissa was a good balance between the two.

WhatsACreel
Автор

taking a systems course and this is a much better explanation than the one given in lecture. really, you're my hero.

delifresh
Автор

By the way, folks, the exponent is biased because it is a two's complement number, which is difficult to order from least to greatest without the offset--ordering allows for easy comparison, which simplifies CPU operations. Since the exponent in single-precision floating point format is eight bits wide, the maximum possible bit combinations it can represent is 2^8 = 256. The "complement" of an eight bit number A is the result when you subtract A from 256. Thus, the complement of 50 is 256 - 50 = 206.

To represent negative numbers, then, we can use the complement of the positive binary number. -50 in binary becomes 11001110 (which is 206 unsigned). It should be clear enough that the maximum possible complements are 128: if you begin at zero (whose complement is 256, with most significant bit ignored), you find that you exhaust them all once you arrive at 127. Thus, positive numbers range from 1 to 127, while negatives range from -1 to -128. Because 0 and 255 are reserved with special meanings, our actual number of possible exponents is 254, which range from -126 to +127. (Divide 254 by 2, giving 127. 0 and 255 are unavailable. Most negative possible value: 1 - 127 = -126. Most positive: 254 - 127 = 127.) Adding 127 to the true value results in a range of numbers from 1 to 254, which is much simpler for comparative purposes.

TheRevScare
Автор

Very good video. You made it easy to understand how to do this by breaking it down to very simple steps.

WYO_Dirtbag
Автор

I had 5 minutes to understand this before my exam because I totally missed that this might be a part of it.
The float question was so easy I think I actually got it thanks to the first minutes of this video.
Thanks fam.

SWHUMMR
Автор

Thanks for the video. It was the most helpful one for me on YouTube. It's so easy if you know what to do. Before that it's a struggle.

Shivatrix
Автор

For something like the atof C++ function each version would be different depending on which headers and libraries the compiler is using.

Converting a binary int to IEEE is very easy with a few shifts.

Thanks for watching and commenting!

WhatsACreel
Автор

Thank you very much for this video! I came here after studying Java and wondering how large a float/double is. After being confused by wikipedia, your video instantly helped me understand. Subscribed and will be consuming your very interesting AES encryption videos shortly!

ryz
Автор

Great tutorial Thank you! I couldn't find nothing such well explained step by step to learn how to handle this ;-)

boasis
Автор

Single-precision floating-point format is a computer number format that occupies 4 bytes (32 bits) in computer memory and represents a wide dynamic range of values by using a floating point. In IEEE 754-2008 the 32-bit base-2 format is officially referred to as binary32. It was called single in IEEE 754-1985.

randomipadgaming
Автор

Comp Architecture class text was vague. This helped a lot. Cheers dude.

TheChrlmgn
Автор

Great video! This has really helped me understand, and perfectly before my exams!

beckmonkey
Автор

I think I've not been clear... Once the digit 1 is recorded I subtract it from the amount we're still to explain. When I say subtract here I don't mean subtract from the bit pattern we've recorded in the mantissa, I mean from the amount we've left to describe. 0.5x2 is 1.0, we record the 1 in the mantissa then subtract it from the amount we've left to describe to get 0.0.

Hope this makes sense, thanks for watching and commenting.

WhatsACreel
Автор

Awesome video, helped me understand how to do the IEEE representation. I was so stuck on this trying to understand my professor's lecture video. You went slowly step by step, awesome job!!

There is one thing I would like to say though for the improvement. The part where you discovered that 1.35703125 is ''normalized'', I think it would be good to mention or at least make explicit that the initial ''1'' is not counted in the 23 bits. I would say that after you put that first 1, then you start counting 23 slots after that. But great job and keep up the good work!!

MrWoopydalan
Автор

For clarification, finding the power of 2 needed to normalize the value of 173.7 is done by performing - log2(173.7), and then to find the normalized value (1.35703125) perform - 173.7/log2(173.7)

kevinparsley
Автор

Are you planning to do a video on floating point arithmetic; add, subtract, multiply and maybe tougher ones like divide or square root? Would be very interesting.

theth
Автор

Assuming you're talking about two IEEE f loats? You'll want to look at operations on scientific notation numbers. If the exponents are the same you can add the mantissas and normalise, don't forget the implied bit. If the exponents differ you have to multiply one of the numbers by a power of 2 till the powers are the same, then add the mantissas and normalise.

Hope this helps, thanks for watching.

WhatsACreel
Автор

Awesome video. The first part is that u r answering the questions?? I understands it very well by looking at the questions being asked and how well explained are ur replies. Thanks for ur time . God bless u

seyalg