Why fprintf('%3.1f',round(-eps)) prints -0.0?
Show older comments
I found some very strange behaviour of the round function in Matlab R2016b (at least for me). I would expect that the round function returns 0 for -eps, but surprisingly the command:
num2hex(round(-eps))
Returns:
8000000000000000
Instead of
num2hex(0) == 0000000000000000
This causes fprintf() to print -0.0. Is this a bug or I just miss something?
1 Comment
James Tursa
on 17 Jan 2017
Side Note: This seems to be consistent among the related functions ceil and fix as well. E.g.,
>> num2hex(round(-eps))
ans =
8000000000000000
>> num2hex(ceil(-eps))
ans =
8000000000000000
>> num2hex(fix(-eps))
ans =
8000000000000000
Accepted Answer
More Answers (1)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!