Detecting inadvertent use of integer division

Peter nospam at nospam.org
Mon Dec 14 23:13:37 PST 2009


Don Wrote:
> BTW, does Python allow integer division of floating point numbers?
> eg, int_a  = float_b // float_c;   ?
> (meaning cast(int)float_b / (cast(int)float_c); ).
Python doesn't have integer division, but floor division, and it's perefctly valid if arguments are floats, as name says it's just floor of true division, also python define modulo on floats, so expression a//b * b + a%b == a is always true for builtin numerc types (except if at least one of arguments being inf, NaN, or b = 0)



More information about the Digitalmars-d mailing list