Multiplying sequences with floats

Caleb Hattingh caleb.hattingh at gmail.com
Wed Mar 29 03:15:23 EST 2006


Hi Dennis

Sure, I get it.  I do most of my work in Delphi, which is, shall we
say, not lax about floating-point types.   Thinking about this more, I
realise my initial interest was in looking at the // operator as
something new, whereas I now see it probably just wraps math.floor();
obviously then, you're going to get whatever the underlying C math
library returns.

As an aside, I also realised that the OP could just subclass list to
make one that works with multiplications against floats: he could
either floor and cast the float to int in the overloaded operator, or
make a fancy system of using the fractional part of the float to
duplicate the list int(floor()) times, then add just the fraction of
the list that approximates most closely the decimal part of the float;
this is assuming the outcome is actually meaningful for any particular
problem.

As I remarked to Christoph, this whole issue is actually a non-issue to
me, and I don't want to give the impression I think there is a problem
here; just interested in the // operator is all :)

regards
Caleb




More information about the Python-list mailing list