cprecision

80 bit floating point arithmetic in C/C++


Let assume a, b are _int64 variables. Need to calculate sqrt((long double)a)*sqrt((long double)b) in high precision 80 bit floating point.

Example. (__int64)(sqrt((long double)a)*sqrt((long double)a) + 0.5) != a in many cases as should be.

Which win32 C/C++ compiler can manage 80 bit floating point arithmetic?


Solution

  • You probably should not be using floating point to take the square root of an integer, especially long double which is poorly supported and might have an approximate (not accurate) sqrtl on some systems. Instead look up integer square root algorithms.