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