Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions std/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,9 @@ real tan(real x) @trusted pure nothrow @nogc
jc trigerr ; // x is NAN, infinity, or empty
// 387's can handle subnormals
SC18: fptan ;
fstp ST(0) ; // dump X, which is always 1
fstsw AX ;
sahf ;
jnp Lret ; // C2 = 1 (x is out of range)
jnp Clear1 ; // C2 = 1 (x is out of range)

// Do argument reduction to bring x into range
fldpi ;
Expand All @@ -789,6 +788,10 @@ trigerr:
}
return real.nan;

Clear1: asm pure nothrow @nogc{
fstp ST(0) ; // dump X, which is always 1
}

Lret: {}
}
else version(D_InlineAsm_X86_64)
Expand All @@ -815,10 +818,9 @@ Lret: {}
jnz trigerr ; // x is NAN, infinity, or empty
// 387's can handle subnormals
SC18: fptan ;
fstp ST(0) ; // dump X, which is always 1
fstsw AX ;
test AH,4 ;
jz Lret ; // C2 = 1 (x is out of range)
jz Clear1 ; // C2 = 1 (x is out of range)

// Do argument reduction to bring x into range
fldpi ;
Expand All @@ -837,6 +839,10 @@ trigerr:
}
return real.nan;

Clear1: asm pure nothrow @nogc{
fstp ST(0) ; // dump X, which is always 1
}

Lret: {}
}
else
Expand Down Expand Up @@ -7174,6 +7180,12 @@ deprecated("Phobos1 math functions are deprecated, use isInfinity ") alias isinf

real r = tan(-2.0L);
assert(fabs(r - 2.18504f) < .00001);

// Verify correct behavior for large inputs
assert(!isNaN(tan(0x1p63)));
assert(!isNaN(tan(0x1p300L)));
assert(!isNaN(tan(-0x1p63)));
assert(!isNaN(tan(-0x1p300L)));
}

@safe pure nothrow unittest
Expand Down