From db561ee7afe4b518f017d12be4deff0d90add6ad Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 18 Jun 2022 19:11:07 -0500 Subject: [PATCH] Bugfix: Add missing endianness check to f_convesion. This just adds the inverse shift on the assumption that the original code is correct and is for little-endian. --- level_0/f_conversion/c/private-conversion.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/level_0/f_conversion/c/private-conversion.c b/level_0/f_conversion/c/private-conversion.c index 0bd7e92..72d0e67 100644 --- a/level_0/f_conversion/c/private-conversion.c +++ b/level_0/f_conversion/c/private-conversion.c @@ -96,7 +96,11 @@ extern "C" { } // for if (data.base == 2) { - work = 0x1 << (digits - 1); + #ifdef _is_F_endian_big + work = 0x1 >> (digits - 1); + #else + work = 0x1 << (digits - 1); + #endif // _is_F_endian_big while (digits--) { @@ -347,7 +351,11 @@ extern "C" { } // for if (data.base == 2) { - f_number_unsigned_t work = 0x1 << (digits - 1); + #ifdef _is_F_endian_big + f_number_unsigned_t work = 0x1 >> (digits - 1); + #else + f_number_unsigned_t work = 0x1 << (digits - 1); + #endif // _is_F_endian_big while (digits--) { -- 1.8.3.1