[PPL-devel] floating point behaviour
piotrm
piotrm at cs.umd.edu
Tue Jun 15 21:36:30 CEST 2010
Apologies if this is not the right place to inquire about this, cannot
seem to find any other outlet:
Is it correct behavior for floating point calculations to be done
differently once ppl.hh is included in a c++ program as well as the
printing of floats? Here is an example of what I'm referring to:
#include <cstdio>
int main() {
double a = 0.50000000000000011102230246251565404236316680908203125;
double b = 0.5f / a;
printf("%0.60f %f %0.60f %f\n", a, a, b, b);
return 0;
}
This prints (for me)
0.500000000000000111022302462515654042363166809082031250000000
0.500000
0.999999999999999777955395074968691915273666381835937500000000 1.000000
If I include ppl, as in below:
#include <cstdio>
#include "ppl.hh"
int main() {
double a = 0.50000000000000011102230246251565404236316680908203125;
double b = 0.5f / a;
printf("%0.60f %f %0.60f %f\n", a, a, b, b);
return 0;
}
I get the following
0.500000000000000111022302462515654042363166809082031250000000
0.500000
0.999999999999999888977697537484345957636833190917968750000000 0.:00000
Notice the strange way the b is printed the second time. I also found
instances where numbers that are close to 0.01 get printed as 0.00:000
Is this perhaps an installation issue on my part? I noticed this using
the OCaml interface, that is, use of ppl changed the behavior of the
float types in OCaml in the same way the behavior is changed in C++
above.
More information about the PPL-devel
mailing list