Home > Back-end > Data type double to a float variable, with the principle of data truncation
Data type double to a float variable, with the principle of data truncation
Time:10-07
Those seven significant figures after the wrong number is how to?
CodePudding user response:
That is not a mistake, it is not accurate expression
Effective digital only 6 ~ 7 float, double valid number is 15 ~ 16
Floating-point and integer, integer within the scope of the integer expression every digital accurately express Floating point is you can see that as a result, 1234567890, the float before six is a valid number, is behind the approximate number
This is not the truncation
CodePudding user response:
Do you think about the number of binary representation Before the decimal point each said 1 2 4 August 16 After the decimal point, each said 0.5 0.25, 0.125, 0.0625, 0.03125,... Digital limited, unable to express each decimal precision, can only be approximate
CodePudding user response:
Float precision is not enough, commissioning tests is to know
CodePudding user response:
With %. 20 f show 2.2-2.1 is not equal to 0.1, computer hardware, programming languages can do ah,
CodePudding user response:
Can have a look at my early wrote a blog https://blog.csdn.net/happy__888/article/details/277587 Float in accordance with the provisions of the IEEE format said the decimal part of 23 bits Means that only 2 ^ 23 floating-point number can be accurate, says in addition are only approximate the 2 ^ 23 seems to be very big, but in fact it is in the middle of a rational part, irrational number and rational number has not been an order of magnitude, far more than rational number