Formatting numbers

Daniel Klein danielk at aracnet.com
Tue May 1 22:04:37 EDT 2001


On Tue, 01 May 2001 23:52:56 GMT, matt at mondoinfo.com (Matthew Dixon Cowles)
wrote:

>On Tue, 1 May 2001 16:13:30 -0700, Daniel Klein <DanielK at jBASE.com>
>wrote:
>
>>Given an integer, 12345, how to format this to 123.45 ?
>
>Here's one way:
>
>>>> 12345/100.0 
>123.45
>
>You need the ".0" or at least the dot in order to force floating-point
>division.

Thanks Matt. This works fine for some numbers but not all. :-( Try it with
123456 to see what I mean.

Dan



More information about the Python-list mailing list