[Tutor] Need a better name for this function

Alan Gauld alan.gauld at btinternet.com
Tue Dec 15 23:08:09 CET 2009

"Richard D. Moores" <rdmoores at gmail.com> wrote

> def float_to_exact_number_stored_in_computer(f):
>   from decimal import Decimal
>   return Decimal.from_float(f)
> I've just borrowed from the doc, but that name is too long, isn't it? 
> Please
> suggest something shorter but still meaningful.

If it were C I'd say f2d()
But since its Python why not float2Decimal()?
Since thats what it actually does...

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list