On Mon, Jul 12, 2010 at 6:15 AM, Brian Candler <b.candler / pobox.com> wrote: > Karthick S. wrote: >> I am new to ruby and found this while experimenting with ruby. >> >> irb(main):010:0> 5.1%0.5 >> => 0.0999999999999996 > > Ruby is no different to any other language which uses binary floating > point arithmetic It isn't relevant to the OPs example, but not all languages produce the results for modulo when presented with negative arguments: http://en.wikipedia.org/wiki/Modulo_operation#Common_pitfalls Ruby, Perl, and MS Excel all return a result with the sign of the divisor, while Java returns a result with the sign of the dividend. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale