Wednesday, January 8, 2014

Re: DecimalField Problem

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

> But one would think that if Django calls it a decimal field, it would convert the float to decimal.
> I suppose I'll do that before writing it out to the file (an XML schema) so it really isn't a big deal, just surprising.

Ah, the "decimal" in DecimalField only refers to how you are supposed to enter the values in a form. Python itself only has float and that's what Django uses internally. Decimal vs. scientific notation is just a matter of how you choose to format the output when converting the float to a string. The default in Python depends on the value:

>>> str(0.1)
'0.1'
>>> str(0.00001)
'1e-05'

> > 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? :-)
>
> Yeah, that was supposed to be sarcastic but it didn't come across well. :-)

Sorry, I only do sarcasm in my native language :-)

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+unsubscribe@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/7B1BA0B2-7303-4C17-AE9D-66F93222C934%40cederstrand.dk.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate