Why is the float type not the same as double? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is the float type not the same as double?

Why is no; float a = 2.2; double b = 2.2; a == b? cout << "he" : cout << "no" ;

24th Nov 2019, 6:31 PM
Андрей Петров
Андрей Петров - avatar
2 Answers
+ 2
Because a is of float type and b is of double type. You are comparing there not of equal references. Comparing float(less type) with higher type double. . float is of 4 bytes normally and double occupies 8 bytes..
24th Nov 2019, 9:14 PM
Jayakrishna 🇮🇳