From 1a0b36e390d6eb3b352da091b07344a3f95577fd Mon Sep 17 00:00:00 2001 From: Vitor Fernandes Date: Thu, 16 Jul 2020 01:29:30 +0100 Subject: [PATCH] Clean code with typedef extraction --- src/bmath/math.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/bmath/math.cpp b/src/bmath/math.cpp index de92f1c..8dee3c7 100644 --- a/src/bmath/math.cpp +++ b/src/bmath/math.cpp @@ -6,6 +6,15 @@ #include #include +typedef union { + struct + { + Int value : 31; + Int signal : 1; + } int_with_msb; + Int signed_int; + } SignedInt; + /** * This will get the most significant bit of the Int value. If the most significant bit is 1 then the number is * 0x11111111 --> equals to -1 integer @@ -25,15 +34,7 @@ inline Int msb(Int value) */ inline Int msb2(Int value) { - typedef union { - struct - { - Int v : 31; - Int signal : 1; - } int_with_msb; - Int sint; - } SInt; - SInt sint = {.sint = value}; + SignedInt sint = {.signed_int = value}; return sint.int_with_msb.signal; };