Quote Originally Posted by wysota View Post
.5 might actually be .49999999999999 on 64b so after flooring this will be 0 Try changing the datatype (for instance to float).
You are right there - have been programming so long in Delphi using their Currency type that I forgot that doubles (and floats) can be a bit inaccurate, I changed the function parameter and return value to floats and i get a correct result.
Quote Originally Posted by wysota View Post
BTW. For banking (or similar) you should use high precision math, for example one of these:
http://www.tc.umn.edu/~ringx004/article-main.html
http://www.nongnu.org/hpalib/
http://gmplib.org/
I will have a look at these.. really need something similar to the pascal currency type...