Home > Back-end >  c
c

Time:10-18

Fabs (t) & lt; 1 e - 6 can think t is zero? If can, how to say greater than zero, and small and zero?

CodePudding user response:

 # include 
# include
# include
using namespace std;
Int main ()
{
Double t=0.00000001;
Cout & lt; <(fabs (t) & lt; 1 e - 6) & lt; Cout & lt; <(t & lt; 0.0) & lt; return 0;
}


Please refer to,

CodePudding user response:

Thanks, the double is not directly write a variable==0, why

CodePudding user response:

Storage form of floating point Numbers, determines its no absolute zero, all want to use a tiny tend to zero value is 0

CodePudding user response:

What is the storage form?

CodePudding user response:

Float is 32-bit, valid number is 6 ~ 7, for float type can fabs is less than 1 e - 6
Double is 64, the valid number is 12 ~ 13, for type double can fabs is less than 1 e - 12

Floating point comparisons, you can see my earlier blog https://blog.csdn.net/happy__888/article/details/280627

CodePudding user response:

refer to the second floor lxy5555y response:
thanks, the type double is not directly write a variable==0, why

Can't, the dangerous way

CodePudding user response:

Why, brother

CodePudding user response:

I can do that but it is best not to