1.0010 DOES NOT EQUAL 1.0010
Mostrar comentarios más antiguos
Hi all,
I have a segment of code that is evaluating curfactor(sc) == 1.0010 as 0 when curfactor(sc) == 1.0010 (should evaluate as 1). Both numbers are exactly 1.0010. I checked the class of both numbers and they are both double. What on Earth is happening here?!
I should note that curfactor is an array of size 1x3, and is defined at the very beginning of the function. The expression that is being evaluated is nested within 2 other helper functions. Maybe it's a scope issue? In any case, someone's breath stinks here, and it's certainly not mine.
Jeff
Respuesta aceptada
Más respuestas (2)
bym
el 10 de Nov. de 2011
0 votos
did you check that they were exactly equal with a variable precision package like the symbolic toolbox?
2 comentarios
Teja Muppirala
el 10 de Nov. de 2011
Using "format hex" will also show the difference:
format hex
X = [(0.1+0.2); 0.3]
Jeff
el 10 de Nov. de 2011
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!