We often use floating-point numbers in programming, but have we ever thought about how they actually work?
Let’s take a look at the following binary number: 1111.1101
How is it converted to a decimal number?
🔹 Integer Part (1111)
Binary value: (1×8) + (1×4) + (1×2) + (1×1) = 15
🔹 Fractional Part (.1101)
Binary value: (1×1/2) + (1×1/4) + (0×1/8) + (1×1/16) = 0.8125
Final Conversion:
1111.1101 (Binary) = 15.8125 (Decimal)
Top comments (2)
short and sweet 👍
thanks