Skip to content

Commit 3298345

Browse files
committed
Ensure JIT_Dbl2ULng correctly handles NaN
1 parent 5d5fb3a commit 3298345

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/coreclr/vm/jithelpers.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,14 @@ HCIMPL1_V(UINT64, JIT_Dbl2ULng, double val)
595595
if (val < two63) {
596596
ret = FastDbl2Lng(val);
597597
}
598-
else {
598+
else if (!_isnan(val)) {
599599
// subtract 0x8000000000000000, do the convert then add it back again
600600
ret = FastDbl2Lng(val - two63) + I64(0x8000000000000000);
601601
}
602+
else {
603+
// specially handle NaN otherwise we return (Int64.MaxValue + 1)
604+
ret = 0;
605+
}
602606
return ret;
603607
}
604608
HCIMPLEND

0 commit comments

Comments
 (0)