aboutsummaryrefslogtreecommitdiff
path: root/src/math/modf_386.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/modf_386.s')
-rw-r--r--src/math/modf_386.s13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/math/modf_386.s b/src/math/modf_386.s
index 3debd3b95d..d549f1d1a0 100644
--- a/src/math/modf_386.s
+++ b/src/math/modf_386.s
@@ -6,6 +6,19 @@
// func Modf(f float64) (int float64, frac float64)
TEXT ·Modf(SB),NOSPLIT,$0
+ // special case for f == -0.0
+ MOVL f+4(FP), DX // high word
+ MOVL f+0(FP), AX // low word
+ CMPL DX, $(1<<31) // beginning of -0.0
+ JNE notNegativeZero
+ CMPL AX, $0 // could be denormalized
+ JNE notNegativeZero
+ MOVL AX, int+8(FP)
+ MOVL DX, int+12(FP)
+ MOVL AX, frac+16(FP)
+ MOVL DX, frac+20(FP)
+ RET
+notNegativeZero:
FMOVD f+0(FP), F0 // F0=f
FMOVD F0, F1 // F0=f, F1=f
FSTCW -2(SP) // save old Control Word