Q36 Is float a = 22/7 and double b = 22/7 is equal? How to compare floating point numbers?

if(a == b) may be true or may not be, that’s because of the way floating point numbers are stored. Data type float takes 4 byte of memory and double takes 8 byte of memory. Float can have ( 8 bit unsigned integer) and a 23 bit fraction but double can have ( 11 bit exponent ) and a 52 bit fraction.

Leave a Reply

Your email address will not be published. Required fields are marked *

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