problem with a simple division

I have variable named, n. where
n =0.0500 ;
whos n shows:
1x1(size) 8(bytes) double(class)
now when i am doing,
z=n/0.001;
it gives me z=49.9997 !!!!!!!! but it should be 50.
When I do it in command line it gives me exact 50 .
What am i doing wrong?
N.B : n is coming from a subtraction of two values from a 'csv' file i am reading by csvread

Respuestas (1)

Roger Stafford
Roger Stafford el 17 de Sept. de 2013

0 votos

To get that far away from 50, your n cannot be equal to 0.0500. It is actually something like 0.0499997 which in "format short" would be displayed as 0.0500 . Try using "format long" and see if this isn't true.

Categorías

Preguntada:

ASM
el 17 de Sept. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by