How do Floating Point Units Convert Decimal Numbers?

0
8
Asked By CuriousCat314 On

I'm curious about how floating point units (FPUs) actually convert numbers. I understand these numbers consist of an exponent, mantissa, and a sign bit. For example, if we consider the integer part of 3, it converts to 11 in binary. But what happens with the decimal part? Like, how does 3.25 get converted, especially since I've heard about this multiply-by-2 method, which seems to assume that floating point arithmetic is already in place?

3 Answers

Answered By BookwormCoder On

If you're looking for more detailed info, check out this resource: https://llvm.org/devmtg/2022-11/slides/QuickTalk3-ApproximatingatScale-StringToFloat.pdf.

Answered By TechWhiz24 On

That's correct, but it's important to note that floating point arithmetic relies on these conversions. Once numbers are converted into their floating point form, the actual calculations are done using that representation.

Answered By BinaryNinja87 On

Here's how the conversion works: First, you turn the number into a fraction. For 3.25, that's 13 divided by 4. Then, convert that fraction into binary, which gives you 11.01. From there, you slide the binary point until you have one '1' in front, resulting in 1.101 times 2 to the power of 1. Finally, you store the sign, the exponent (how far the point was slid), and the bits after the first '1' which make up the mantissa.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.