Tuesday, June 28, 2011

Re: Curious int/float/division/math 'gotcha' in py (discussion)

On Tue, Jun 28, 2011 at 2:23 PM, Cal Leeming [Simplicity Media Ltd]
<cal.leeming@simplicitymedialtd.co.uk> wrote:
> I'm wondering if it's better practise to always cast a number as a
> float/decimal, rather than an int.
> Any thoughts guys?
> Cal

Damn, this was the bit I meant to comment upon - hard and fast rules
are dangerous. Integral types are distinctly different to floating
point types, and you should be aware of which one you are using and
why. You definitely should not be using floats when you require
integral mathematics, or reliable accounting since 1.0 is only an
approximation to 1.



>>> 1.0 * 10000000000000000000000000000

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment