Python -- floating point arithmetic

Zooko O'Whielacronx zooko at zooko.com
Thu Jul 8 15:15:08 EDT 2010


On Thu, Jul 8, 2010 at 11:22 AM, Adam Skutt <askutt at gmail.com> wrote:
> On Jul 8, 12:38 pm, "Zooko O'Whielacronx" <zo... at zooko.com> wrote:
>> Now as a programmer you have two choices:
…
>> 1. accept what they typed in and losslessly store it in a decimal:
…
>> 2. accept what they typed in and lossily convert it to a float:

> No, you have a third choice, and it's the only right choice:
> 3. Convert the input to user's desired behavior and behave
> accordingly.  Anything else, here, will result in A/V sync issues.

Okay, please tell me about how this is done. I've never dealt with
this sort of issue directly.

As far as I can imagine, any way to implement option 3 will involve
accepting the user's input and storing it in memory somehow and then
computing on it. As far as I can tell, doing so with a decimal instead
of a float will never be worse for your outcome and will often be
better. But, please explain in more detail how this works.

Thanks!

Regards,

Zooko



More information about the Python-list mailing list