Social Icons

Showing posts with label IEEE-754. Show all posts
Showing posts with label IEEE-754. Show all posts

Sunday, December 12, 2021

Why 0.1 + 0.2 = 0.30000000000000004 ?

Have you ever tried simple calculations in usual programming languages like python, ruby, rust or Java etc 

0.1 + 0.2 = 0.30000000000000004 or 

0.1 + 0.7 = 0.7999999999999999 or 

0.2 + 0.7 = 0.8999999999999999 or 0.3 - 0.1 = 0.19999999999999998 

Why do the results show something unexpected? The reason pertains to IEEE standard IEEE-754 that defines 32bit/64 bit formats for storage of numbers in computers. This presentation tries to bring out simply of where the anomaly exists and why do we get these results. Also reaffirms that the normal IEEE-754 floating point standard will not befit for usual finance and banking applications wherein few zero's can lead to undesired losses for some and unexpected gains for few.

Powered By Blogger