Problem with mod and the value 2.3 times 100

1 vue (au cours des 30 derniers jours)
Katsmeat
Katsmeat le 14 Juin 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?

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Juin 2015

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by