On Fri, Jan 13, 2017 at 12:09 AM, George Fischhof <geo...@fischhof.hu> wrote: > from __future__ import use_decimal_instead_of_float > or any other import would be very good. > The most important thing in my point of view is that I do not want to > convert every variable every time to decimal. > Accuracy is important for me (yes, 0.1 + 0.2 should equal to 0.3 , no more, > no less ;-) ) > > And if it is mentioned, I would like to ask why binary floating point is > "better". It is faster, I agree, but why "better"? > > Actually I create test automation (I am a senior QA eng), the fastest test > case runs for about 1-2 minutes. I do not know the exact time difference > between binary and decimal arithmetic, but I do not care with this. My test > would run some microseconds faster. It does not matter at a minute range. > > In the tests I calculate with numbers with 4 decimal digits, and I need > exact match. ;-) > > Actually I have a new colleague, they did image analysis, and the calculated > much calculations, and they used a library (not python) that is accurate as > well. Becasue accuracy was more important for them as well.
Sounds like you want integer arithmetic. When you're working with something that goes to a known number of decimal places (eg money), it's often easiest and safest to redefine your unit (eg cents rather than dollars, or millimeters instead of meters) so you can use integers everywhere. Accurate AND fast! ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/