Problem with mod and the value 2.3 times 100

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 14 Giu 2015

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by