Changed to a more efficient implementation.

This commit is contained in:
Matthijs Hofstra 2013-05-29 20:21:04 +02:00
parent 6cc9a26a2d
commit 3141acf674
2 changed files with 4 additions and 16 deletions

View File

@ -147,18 +147,12 @@ pub fn gt(x: f32, y: f32) -> bool { return x > y; }
#[inline(always)]
pub fn fmax(x: f32, y: f32) -> f32 {
if x.is_NaN() { y }
else if y.is_NaN() { x }
else if x > y { x }
else { y }
if x >= y || y.is_NaN() { x } else { y }
}
#[inline(always)]
pub fn fmin(x: f32, y: f32) -> f32 {
if x.is_NaN() { y }
else if y.is_NaN() { x }
else if x < y { x }
else { y }
if x <= y || y.is_NaN() { x } else { y }
}

View File

@ -172,18 +172,12 @@ pub fn gt(x: f64, y: f64) -> bool { return x > y; }
#[inline(always)]
pub fn fmax(x: f64, y: f64) -> f64 {
if x.is_NaN() { y }
else if y.is_NaN() { x }
else if x > y { x }
else { y }
if x >= y || y.is_NaN() { x } else { y }
}
#[inline(always)]
pub fn fmin(x: f64, y: f64) -> f64 {
if x.is_NaN() { y }
else if y.is_NaN() { x }
else if x < y { x }
else { y }
if x <= y || y.is_NaN() { x } else { y }
}
// FIXME (#1999): add is_normal, is_subnormal, and fpclassify