octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: R: float to integer conversion anomalies


From: Levente Torok
Subject: Re: R: float to integer conversion anomalies
Date: Tue, 30 Jun 2009 12:36:02 +0200
User-agent: KMail/1.11.4 (Linux/2.6.28-13-generic; KDE/4.2.4; x86_64; ; )

On Tuesday 30 June 2009, you wrote:
> 
> > 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
> 
> may I suggest 
> for i=.1:.1:2
>   round(i*10)
> endfor
>

> You are missing some ground on 0.3 representation in base 2.  
> It is a periodic number so must be truncated.
Sounds reasonable from programming point of view however not from the point of 
the user who doesn't know much
about radixes. Or should he?

Lev

-- 
Blogger of http://fapuma.blogspot.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]