From: Josh Cheek Date: 2011-03-30T06:50:24+09:00 Subject: Re: Why can a floating point number be used as an array index? --00221534ca37df88d2049fa60baf Content-Type: text/plain; charset=ISO-8859-1 On Tue, Mar 29, 2011 at 3:59 PM, Xavier Noria wrote: > On Tue, Mar 29, 2011 at 10:38 PM, wrote: > > > It may do integer truncation, but we need to think of what an Array > > actually is as far as the structure goes. What would one expect to get > out > > of [0,1,2][0.3] ? Should it be 30% of the first element? That doesn't > seem > > right. > > Well, alternatively you could get an error. > > Seems a lot more reasonable, using floats could introduce errors: # almost one 123.6 - 123 + 0.4 # => 0.9999999999999943 # but truncates to zero (123.6 - 123 + 0.4).truncate # => 0 # do the same math with integers (1236 - 1230 + 4) / 10 # => 1 --00221534ca37df88d2049fa60baf--