Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rounding
#1
I have developed an app, which does lengthy, but not very complicated calculations.
The main thing is that it produces end results, rounded numbers to 2 decimals.
Works well. (On my PC)

I made an executable with pyinstaller : pyinstaller --onefile --windowed xxx.py,
and gave it to somebody else.

With the identical dataset, his results are the same except for the rounding.
I have eg. : 616.51
His PC produces : 616.5199999999999

Am I naive in thinking that an executable should always produce the exact same result als the source?
How can this be ? Huh
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#2
Please see: https://docs.oracle.com/cd/E19957-01/806...dberg.html
Reply
#3
...or... try the calculations with the decimal.Decimal type. actually, read that document, anyway, first. then read about the decimal.Decimal type.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
wow, all this is not for the faint of heart.
Will try to make some sense of it.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#5
(Jul-04-2022, 05:08 PM)DPaul Wrote: wow, all this is not for the faint of heart.
the same can be said for many other things when you dive deep into programming. get used to it.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020