FPU: sqrt(-0) == 0

It is marked as a special case in the doc (sqrt(-0) == -0)
but test on the PS2 show the contrary. Quite a mistery
This commit is contained in:
Gregory Hainaut committed 2016-01-31 23:43:55 +01:00
1 parent 6391b00c00
commit 3ec458ef4f
1 file changed
+4 -3
+4 -3
View File
@@ -345,12 +345,13 @@ void RSQRT_S() {
}
void SQRT_S() {
if ( ( _FtValUl_ & 0xFF800000 ) == 0x80000000 ) { _FdValUl_ = 0x80000000; } // If Ft = -0
if ( ( _FtValUl_ & 0x7F800000 ) == 0 ) // If Ft = +/-0
_FdValUl_ = 0;// result is 0
else if ( _FtValUl_ & 0x80000000 ) { // If Ft is Negative
_ContVal_ |= FPUflagI | FPUflagSI;
_FdValf_ = sqrt( fabs( fpuDouble( _FtValUl_ ) ) );
}
else { _FdValf_ = sqrt( fpuDouble( _FtValUl_ ) ); } // If Ft is Positive
} else
_FdValf_ = sqrt( fpuDouble( _FtValUl_ ) ); // If Ft is Positive
clearFPUFlags( FPUflagD );
}