OMG !!
I am getting 8.93 on g++ 3.4.4 (linux ) and g++ (GCC) 3.4.2 (mingw-special) Windows
OMG !!
I am getting 8.93 on g++ 3.4.4 (linux ) and g++ (GCC) 3.4.2 (mingw-special) Windows
We can't solve problems by using the same kind of thinking we used when we created them
got me puzzled..
g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)
I am using fedora core 7 x86_64
.5 might actually be .49999999999999 on 64b so after flooring this will be 0Try changing the datatype (for instance to float).
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/
sunil.thaha (25th June 2007)
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.
I will have a look at these.. really need something similar to the pascal currency type...
See this: http://quantlib.org/
Bookmarks