From: Alex Gutteridge Date: 2007-08-30T10:31:11+09:00 Subject: Re: Bug in % (Float)? On 30 Aug 2007, at 09:02, Charlie Lehardy wrote: > So, can anybody tell me what's going on here? Are things really > broken, or am I just > expecting the wrong results? > > Thanks, > Charlie As Florian says, the problem is inherent with floating point values. The Python docs have a good section which explains how 0.1 cannot be represented as a binary fraction: http://docs.python.org/tut/node16.html Ruby just uses your systems C functions (fmod in this case) to do these calculations and they show the same behavior: [alexg@powerbook]/Users/alexg/Desktop(209): cat test.c #include #include int main(){ printf("fmod of 1 / 0.1 is %lf\n",fmod(1,0.1)); return 0; } [alexg@powerbook]/Users/alexg/Desktop(210): gcc -lm test.c -o modtest [alexg@powerbook]/Users/alexg/Desktop(211): ./modtest fmod of 1 / 0.1 is 0.100000 Alex Gutteridge Bioinformatics Center Kyoto University