Python 2.3.7 has the following functions as number converters: float(num), int(num), long(num). But what happened to double(num)?
If my number is a=3.33333 and do round(_,2), the output I get is 3.3300000000000001. I was expecting to see 3.33.
What’s happening to here?
Thank you.
liliya
l_w
0
Newbie Poster
Recommended Answers
Jump to PostIt gets weirder. Check this out
a = 3.333333 round(a,2) # output> 3.3300000000000001 a = round(a,2) a # output> 3.3300000000000001 print a # output> 3.33
What's up with that?
Jump to PostThis is a well know and well documented result on PCs due to the use of binary numbers. Our base 10 system also has problems (with numbers like 1/3 or Pi). The explaination at
Jump to Postwhy not go for Python 2.5 ?
Jump to Postwhy not go for Python 2.5 ?
Yes, decimal was first included in Python 2.4 http://www.python.org/doc/2.5.2/lib/module-decimal.html On linux, upgrading is as simple as telling the package manager to upgrade. For MS Windows,
All 13 Replies
mn_kthompson
3
Junior Poster
l_w
0
Newbie Poster
woooee
814
Nearly a Posting Maven
l_w
0
Newbie Poster
l_w
0
Newbie Poster
Stefano Mtangoo
455
Senior Poster
woooee
814
Nearly a Posting Maven
l_w
0
Newbie Poster
woooee
814
Nearly a Posting Maven
l_w
0
Newbie Poster
woooee
814
Nearly a Posting Maven
l_w
0
Newbie Poster
l_w
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.