I have a numeric value, possibly a float, Decimal or (improper) Fraction, and I want the fractional part. E.g. fract(2.5) should give 0.5.
Here are two ways to do it: py> x = 2.5 py> x % 1 0.5 py> x - int(x) 0.5 x % 1 is significantly faster, but has the disadvantage of giving the complement of the fraction if x is negative: py> x = -2.75 py> x % 1 0.25 Are there any other, possibly better, ways to calculate the fractional part of a number? -- Steven -- https://mail.python.org/mailman/listinfo/python-list