fix f64 tcc eq crash
parent
ae3ec380f8
commit
91690a1b54
|
@ -28,17 +28,25 @@ pub fn ptr_str(ptr voidptr) string {
|
||||||
// compare floats using C epsilon
|
// compare floats using C epsilon
|
||||||
// ==
|
// ==
|
||||||
pub fn (a f64) eq(b f64) bool {
|
pub fn (a f64) eq(b f64) bool {
|
||||||
|
$if windows {
|
||||||
$if tinyc {
|
$if tinyc {
|
||||||
return a -b <= 0.01
|
return a -b <= 0.01
|
||||||
} $else {
|
} $else {
|
||||||
return C.fabs(a - b) <= C.DBL_EPSILON
|
return C.fabs(a - b) <= C.DBL_EPSILON
|
||||||
}
|
}
|
||||||
|
} $else {
|
||||||
|
return C.fabs(a - b) <= C.DBL_EPSILON
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn (a f32) eq(b f32) bool {
|
pub fn (a f32) eq(b f32) bool {
|
||||||
|
$if windows {
|
||||||
$if tinyc {
|
$if tinyc {
|
||||||
return a -b <= 0.01
|
return a -b <= 0.01
|
||||||
} $else {
|
} $else {
|
||||||
return C.fabsf(a - b) <= C.FLT_EPSILON
|
return C.fabs(a - b) <= C.DBL_EPSILON
|
||||||
|
}
|
||||||
|
} $else {
|
||||||
|
return C.fabs(a - b) <= C.DBL_EPSILON
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn (a f64) eqbit(b f64) bool {
|
pub fn (a f64) eqbit(b f64) bool {
|
||||||
|
|
Loading…
Reference in New Issue