[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
float to integer conversion anomalies
From: |
Levente Torok |
Subject: |
float to integer conversion anomalies |
Date: |
Tue, 30 Jun 2009 11:16:31 +0200 |
User-agent: |
KMail/1.11.4 (Linux/2.6.28-13-generic; KDE/4.2.4; x86_64; ; ) |
Hi All,
May be I am commenting something that has already been reported or even solved.
On octave-3.0.5 I found a somewhat inconsistent behavior.
octave:2> for i=.1:.1:2
> i*10
> endfor
ans = 1
ans = 2
ans = 3.00000000000000 <-????
ans = 4
ans = 5
ans = 6
ans = 7.00000000000000 <-????
ans = 8
ans = 9
ans = 10
ans = 11
ans = 12.0000000000000
ans = 13.0000000000000
ans = 14.0000000000000
ans = 15.0000000000000
ans = 16
ans = 17
ans = 18.0000000000000
ans = 19
ans = 20
Which is not a problem as long as I don't want to index with this. But if I do
I got error message.
octave:3> for i=.1:.1:2
> z(i*10)=1;
> endfor
error: expecting integer index, found 3.000000
error: assignment failed, or no method for `matrix = scalar'
error: evaluating assignment expression near line 4, column 8
error: evaluating for command near line 3, column 1
Levente
--
Blogger of http://fapuma.blogspot.com
- float to integer conversion anomalies,
Levente Torok <=