-1
static const double sKPrecision = 1.e+16;
std::sprintf(str, "%1.15e", round(val * sKPrecision) / sKPrecision);

Observation:

val        str for Linux           str for QNX
-0.174533  -1.745329251994333e-01  -1.745329251994333e-01
1.06202    1.062015382745040e+00   1.062015382745040e+00
1.63244    1.632439935370810e+00   1.632439935370811e+00

As per the above table, for 1.63244 the "str" is different for QNX than Linux. I want this value to be same as that of Linux. I am not sure how to solve it for QNX platform.

Swapnil
  • 1,424
  • 2
  • 19
  • 30

1 Answers1

0

Start here: Enabling strict floating point mode in GCC and GCC Wiki - Floating Point Math

Other things to consider:

  • Are you using the same processor for both?
  • Are both running in 32 bit mode (AFAIK as of 2/2016, QNX does not have a 64 bit version)?
  • If running x86, is the compile loading intermediate values from the FPU back to registers (i.e. truncating 80 bit math to 64 bit) or are all values kept in the FPU (80 bit)? (see: This answer about the -ffloat-store flag.)
Community
  • 1
  • 1
jwernerny
  • 6,978
  • 2
  • 31
  • 32