General information
Category:
Coding, syntax & commands
I agree that it's not the best way to do such calculations (though for some calculations, setting it out in such a manner, clarifies what is being done, without the need for explicit comments).
But it is a matter of some concern that
a = 0.3500000000
b = 943
c = .1
round( a * b * c, 2 ) # round( 0.3500000000 * 943 * .1, 2 )
e.g. where else are such little discrepancies hidden, should all use of literals in expressions be avoided ?
A lot of the code I produce is used in calculating duty payable to Customs & Excise, from calculations similar to these. All of the calculations use variables, so no (apparent) problem. If checks were performed on my results though, two seemingly identical calculations, as above, returning different results could seriously undermine the clients view of the reliability of the entire system.
Paul
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only