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

답변 (1개)

Roger Stafford
Roger Stafford 2013년 9월 17일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

질문:

ASM
2013년 9월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by