At least in some environments sqrt() is for doubles, sqrtf() for floats and sqrtl() for long doubles.
Yes. Math. H has version: long double sqrt(long double) – amuliar Aug 10 '11 at 19:27 1 The sqrt() function declared in is definitely for doubles, not for long double; sqrtl() is for long doubles.
But there's also a "type-generic macro" sqrt() defined in (if your compiler supports it, it's a relatively new feature). – Keith Thompson Aug 10 '11 at 19:28 @amuliar: It's called "sqrtl", not "sqrt". – Keith Thompson Aug 10 '11 at 19:28 1 I thought sqrtl was a Pkmn... – R.. Aug 10 '11 at 20:00 Open Watcom C/C++ compiler has only sqrt version.
:( – amuliar Aug 10 '117 at 8:19.
Embarcadero's C++Builder will handle 80 bit floating point. Use the long double type, or the (imported from Delphi) Extnded type. They are the same.
Yes it has 80 bit, but it fails. A = 8642673492431640625L; Result in Delphi: 8642673492431640624. Borland C++ Compiler 5.5: 8642673492431640200 – amuliar Aug 11 '11 at 12:19 OK, I just tried: unsigned __int64 a = 8642673492431640625L; long double ld = a; printf("%0.1Lf\n", ld); and it prints: 8642673492431640625.0, which seems correct, to me.
That was in C++Builder XE. – Rudy Velthuis Aug 11 '11 at 17:08.
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.
It is more difficult. I am searching for solutions system of diofant equations (lim. To 64 bit integers).
The form of INTEGER NUMBER sqrtl(a)*sqrtl(b) is most simple representation of possible solution. – amuliar Aug 11 '11 at 7:59 I mean there are ways you can perform square roots on integers directly without using floating point. – R.. Aug 11 '11 at 12:48.