Den 08/01/2014 kl. 16.18 skrev Timothy W. Cook <t...@mlhim.org>:

> I have several decimal fields defined in the model like this:
> 
> min_inclusive = models.DecimalField(_('minimum inclusive'), max_digits=19, 
> decimal_places=10, help_text=_("Enter the minimum (inclusive) value for this 
> concept."), null=True, blank=True)
> 
> Via the admin interface when I enter a 0 (zero)  and save the object I get 
> 0E-10 as the value.  I am using PostgreSQL 9.1 for persistence. 
> 
> So, why doesn't it just store a zero? 

Underneath a DecimalField there is a Python float type, and some equivalent 
float type in your database. Float values are an approximation, so 
0.000000000000 and 0 are not guaranteed to be equal. See 
http://stackoverflow.com/questions/2986150/python-floating-number

> In reality I need to allow the range of,  positive infinity to negative 
> infinity.  But this doesn't seem possible.  Is it?

It’s not physically or computationally possible. How will you store an infinite 
number of digits on a hard drive of finite size? :-)

Erik

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4A347EEF-D57A-48A8-9E49-7F357546492B%40cederstrand.dk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to