Now that I have the answer (16.800000000000001), How do I round it of
to 16.80 ? I only need it to be to the closest 1/100. TIA Jorge Godoy wrote: Frank Moore <[EMAIL PROTECTED]> writes:Johan, You could try: percentage = (42 * 250)/100 This gives the answer 105.And that sounds weird, doesn't it? 42 is smaller than 250, so I'd expect it to be less than 100% of the value... In fact, it is42.0/2500.16800000000000001(42.0/250)*10016.800000000000001I suspect the problem is due to the fact that Python does integer division by default:42/2500So, how to make it generic?a = 42 b = 250 a / b0float(a)/b0.16800000000000001One of the members has to be a floating point so that floating point division is performed instead of integer division. Be seeing you, |
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor