Tuesday 21 February 2017

c++ - How many decimal places does the primitive float and double support?




I have read that double stores 15 digits and float stores 7 digits.



My question is, are these numbers the number of decimal places supported or total number of digits in a number?



Answer



Those are the total number of "significant figures" if you will, counting from left to right, regardless of where the decimal point is. Beyond those numbers of digits, accuracy is not preserved.



The counts you listed are for the base 10 representation.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...