0

I'am runing a C++ software with double variables. My platform is upboard with an Intel® Atom™ x5-z8350 (1.92 GHz). The OS is Ubuntu server 18.04 and I compile the software with GCC 7.5.0. I compile my .cpp only with the optimization flag -o2.

How can I find / what is the size of the mantissa for the double variable floating point representation? Is is the standard 64-bit format with 53 bits mantissa or the x86/x86-64 80-bit format with 64 bits mantissa?

Thank you very much. Gabriel

Gabriel Laupre
  • 151
  • 1
  • 9
  • Generally speaking, all x86-64 platforms use standard IEEE 754 definition. It's extremely rare to find a non-conforming chip. – iBug Jun 09 '22 at 09:18
  • 3
    Check [`std::numeric_limits::digits`](https://en.cppreference.com/w/cpp/types/numeric_limits/digits). – Daniel Langr Jun 09 '22 at 09:19
  • The problem is that the FPU internally has more bits but every time a double is saved to memory you loose those. So the numeric limits might not be totally accurate unless you set a compiler option to enforce IEEE conformance. – Goswin von Brederlow Jun 09 '22 at 09:20
  • 1
    @GoswinvonBrederlow With x64, floating-point calculations are typically performed by SIMD units, not by FPU (x87). Some implementations use FPU for `long double` calculations. Live demo: https://godbolt.org/z/6GTePPdEc. – Daniel Langr Jun 09 '22 at 09:22
  • On non-Windows, GCC uses 80-bit `long double`. If you really want that extra precision at the cost of speed, use that type. – Peter Cordes Jun 09 '22 at 09:26
  • @DanielLangr Then setting the ieee compliance flag won't hurt performance. I know at least gcc used to have the problem of playing loose with using the 80-bit format in the fpu. – Goswin von Brederlow Jun 09 '22 at 09:28
  • @GoswinvonBrederlow: I think you're talking about `-ffloat-store` to force rounding of temporaries to the actual C type. You're right, that has no effect on x86-64 builds because `-mfpmath=sse` is the default. `-fno-fast-math` is also the default. – Peter Cordes Jun 09 '22 at 18:50

0 Answers0