H
horati0
not really an oddity, more a lack of understanding on my part regarding
ruby's internal type conversion...
(100*(1.15-1))
=> 15.0
(100*(1.15-1)).to_int
=> 14
(100*(1.15-1)).to_int.round
=> 15
15.0.to_int
=> 15
what am i missing here? i never would have thought to use .round to
get the 'correct' result unless someone told me. by correct i mean if
i was doing this with a paper and pencil, i would expect to get 15, not
14.
any insight would be appreciated, especially a way (if possible) to
override this behaviour so i dont run into this in the future.
thanks,
horati0
ruby's internal type conversion...
(100*(1.15-1))
=> 15.0
(100*(1.15-1)).to_int
=> 14
(100*(1.15-1)).to_int.round
=> 15
15.0.to_int
=> 15
what am i missing here? i never would have thought to use .round to
get the 'correct' result unless someone told me. by correct i mean if
i was doing this with a paper and pencil, i would expect to get 15, not
14.
any insight would be appreciated, especially a way (if possible) to
override this behaviour so i dont run into this in the future.
thanks,
horati0