summaryrefslogtreecommitdiff
path: root/src/math/i386/sqrtf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/i386/sqrtf.c')
-rw-r--r--src/math/i386/sqrtf.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/math/i386/sqrtf.c b/src/math/i386/sqrtf.c
new file mode 100644
index 00000000..41c65c2b
--- /dev/null
+++ b/src/math/i386/sqrtf.c
@@ -0,0 +1,12 @@
+#include <math.h>
+
+float sqrtf(float x)
+{
+ long double t;
+ /* The long double result has sufficient precision so that
+ * second rounding to float still keeps the returned value
+ * correctly rounded, see Pierre Roux, "Innocuous Double
+ * Rounding of Basic Arithmetic Operations". */
+ __asm__ ("fsqrt" : "=t"(t) : "0"(x));
+ return (float)t;
+}