How to replace last 3 digits in a floating point number by another 3 digits
6 views (last 30 days)
More Answers (1)
Walter Roberson on 5 Dec 2019
>> fprintf('%.999g\n', -3.141592653589793)
The last 3 digits of x are 875 not 393 .
MATLAB does not store numbers in decimal; it stores them in IEEE 754 Double Precision. It is not possible to exactly represent 1/10 in any finite number system based upon powers of 2, for exactly the same reason that you cannot exactly represent 1/7 in any file number system based upon powers of 10.