From 1a2c8175d4e1fcfd3ccb7f52c1de009f00ed7bd2 Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Tue, 1 Apr 2025 02:40:23 -0400 Subject: [PATCH] printf: Use f64::abs --- src/header/stdio/printf.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/header/stdio/printf.rs b/src/header/stdio/printf.rs index d4224fc9d5..f04d4ca87d 100644 --- a/src/header/stdio/printf.rs +++ b/src/header/stdio/printf.rs @@ -342,15 +342,6 @@ fn pad( Ok(()) } -fn abs(float: c_double) -> c_double { - // Don't ask me whe float.abs() seems absent... - if float.is_sign_negative() { - -float - } else { - float - } -} - fn float_string(float: c_double, precision: usize, trim: bool) -> String { let mut string = format!("{:.p$}", float, p = precision); if trim && string.contains('.') { @@ -369,11 +360,11 @@ fn float_string(float: c_double, precision: usize, trim: bool) -> String { fn float_exp(mut float: c_double) -> (c_double, isize) { let mut exp: isize = 0; - while abs(float) >= 10.0 { + while float.abs() >= 10.0 { float /= 10.0; exp += 1; } - while f64::EPSILON < abs(float) && abs(float) < 1.0 { + while f64::EPSILON < float.abs() && float.abs() < 1.0 { float *= 10.0; exp -= 1; }