mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-08-02 04:20:05 +02:00
Fix real comparison for real: allow +0 to be distinguished from -0.
This commit is contained in:
@@ -1494,11 +1494,12 @@ complex_t RealExp::toComplex()
|
|||||||
|
|
||||||
int RealEquals(real_t x1, real_t x2)
|
int RealEquals(real_t x1, real_t x2)
|
||||||
{
|
{
|
||||||
return (isnan(x1) && isnan(x2)) ||
|
return // special case nans
|
||||||
/* In some cases, the REALPAD bytes get garbage in them,
|
(isnan(x1) && isnan(x2)) ||
|
||||||
* so be sure and ignore them.
|
// and zero, in order to distinguish +0 from -0
|
||||||
*/
|
(x1 == 0 && x2 == 0 && 1./x1 == 1./x2) ||
|
||||||
x1 == x2;
|
// otherwise just compare
|
||||||
|
(x1 != 0. && x1 == x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RealExp::equals(Object *o)
|
int RealExp::equals(Object *o)
|
||||||
|
|||||||
Reference in New Issue
Block a user