From: Brendan Hansen Date: Mon, 18 Dec 2023 04:42:00 +0000 (-0600) Subject: fixed: #87 by removing unnecessary check X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=52d593a9779d1c89e7b899ea48afec763cc1ae71;p=onyx.git fixed: #87 by removing unnecessary check --- diff --git a/core/conv/conv.onyx b/core/conv/conv.onyx index 80b96f35..90f24698 100644 --- a/core/conv/conv.onyx +++ b/core/conv/conv.onyx @@ -148,7 +148,7 @@ str_to_f64 :: (s: &str) -> f64 { """ i64_to_str :: (n: i64, base: u64, buf: [] u8, min_length := 0, prefix := false) -> str { is_neg := false; - if n < 0 && base == 10 { + if n < 0 { is_neg = true; n = -n; } diff --git a/tests/bugs/format_negative_other_base b/tests/bugs/format_negative_other_base new file mode 100644 index 00000000..09fc1403 --- /dev/null +++ b/tests/bugs/format_negative_other_base @@ -0,0 +1,3 @@ +-4660 +-1234 +-2844 diff --git a/tests/bugs/format_negative_other_base.onyx b/tests/bugs/format_negative_other_base.onyx new file mode 100644 index 00000000..309d9a27 --- /dev/null +++ b/tests/bugs/format_negative_other_base.onyx @@ -0,0 +1,11 @@ +package main + +use core + +main :: () { + a: i32 = -0x1234; + + core.printf("{}\n", a); + core.printf("{x}\n", a); + core.printf("{b12}\n", a); +}