+ 4
How is float stored in c++? How can two float numbers be compared?
5 Respostas
+ 2
floats in c++ are stored as they are in computers generally, it has bits dedicated to the sign, exponent and mantissa. read more here:
https://en.m.wikipedia.org/wiki/IEEE_754
+ 2
The problem is that doing maths with floats is inexact, so you need to do "inexact comparison" too. It really depends on your application though.
https://code.sololearn.com/cfpN6pnAjVNk/?ref=app
+ 1
To store the float c++ followed IEEE-745 standard. Please Google it read more about IEEE standard.
you can compare two float using if condition.
float ft=5.35;
if (5.35f == ft)
cout<<"Match found"<<endl;