From: Gary Wright Date: 2011-09-18T14:08:24+09:00 Subject: Re: Strange vector behaviour On Sep 17, 2011, at 10:26 PM, thomas Mulvaney wrote: > Vector[2,4,6] == Vector[1,2,3]*2 > #=> true > > It returns true as expected. > [...] > Vector[1.1,2.2,3.3] == Vector[1,2,3]*1.1 > #=> false > > Any ideas whats going on? Integer literals have exact representations while floats do not. Decimal floating point numbers in general can not be represented exactly in binary so there is a conversion from the string "1.1", for example, to the binary floating point number that is "closest" to 1.1: >> "%0.60f" % 1.1 #=> "1.100000000000000088817841970012523233890533447265625000000000" Of course this means that multiple of 1.1 aren't exactly what you might expect: >> "%0.60f" % (1.1 * 3) #=> "3.300000000000000266453525910037569701671600341796875000000000" Here is the obligatory reference for this topic: Gary Wright