Re: An interesting problem
- From: "Nasser Abbasi" <nma@xxxxxxxxx>
- Date: Mon, 11 May 2009 00:33:58 -0700
"umar " <umarkhan_80@xxxxxxxxxxx> wrote in message
news:gu8ibm$jb9$1@xxxxxxxxxxxxxxxxxxxxx
hi,
I tried the following code
i=0;
x=0;
for i=1:10
x=x+0.1
end
x-1
at the end x-1 should be zero, but it turns out to be -1.1102e-016 , WHY?
If you want exact values, use symbolic computation.
EDU>> clear all
syms x;
x=sym(0);
for i=1:10
x=x+sym(.1);
end
x=double(x);
x-1
0
--Nasser
.
- References:
- An interesting problem
- From: umar
- An interesting problem
- Prev by Date: Re: fft on square wave
- Next by Date: Re: Help display temporary value of variable in vector
- Previous by thread: Re: An interesting problem
- Next by thread: Re: An interesting problem
- Index(es):
Relevant Pages
|
Loading