floating point math results question
Bengt Richter
bokr at oz.net
Fri Jan 25 17:16:22 EST 2002
On Fri, 25 Jan 2002 16:01:50 GMT, Courageous <jkraska at san.rr.com> wrote:
>
>>The results should be 0.8 and that's it.
>
>First, this question is raised here often. Search http://www.dejanews.com
>for detailed discussion on the matter.
>
>Second, as an academic exercise, you may now attempt to represent the
>number 0.8 as a 32 bit binary value. Summarize and we'll review. :-)
>>> rep = (4<<16)|5
>>> print '%5.2f' % (float(rep>>16)/(rep & ((1<<16)-1) ),)
0.80
>>>
You didn't say what kind or representation ;-)
Regards,
Bengt Richter
More information about the Python-list
mailing list