Problem with mod and the value 2.3 times 100
2 views (last 30 days)
Show older comments
Katsmeat
on 14 Jun 2015
Answered: Walter Roberson
on 14 Jun 2015
There seems to be some kind of overflow problem with mod, which occurs on all the Matlab versions I have access to - 2007a, 2010a and 2014b.
> format long
> mod(2.3*100,10)
> 9.999999999999972
mod(230,10) is fine and gives the right value, zero, but
> qqq=2.3*100
> mod(qqq,10)
Also misbehaves. However
> qqq=2.3*10*10
> mod(qqq,10)
Is fine and does give a result of zero. I'm confused. I was going to submit a bug report, but it seems odd that a bug so easily found could be hanging around for so long. Could somebody offer some insight as to what's going on?
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Graphics Object Programming 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!