From 290e3ea85e5eceae86e469a1b5e131ee80e7d2c2 Mon Sep 17 00:00:00 2001 From: Vitor Fernandes Date: Thu, 16 Jul 2020 01:27:09 +0100 Subject: [PATCH] Code alignment documentation --- src/bmath/math.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bmath/math.cpp b/src/bmath/math.cpp index f4afbee..de92f1c 100644 --- a/src/bmath/math.cpp +++ b/src/bmath/math.cpp @@ -20,6 +20,8 @@ inline Int msb(Int value) * with the help of union and struct trickery. * We basically define a new Union datatype named SInt we use the structure int_with_msb as a way to de-structure * the Int sint information. + * More on unions + * https://www.geeksforgeeks.org/union-c/ */ inline Int msb2(Int value) { @@ -31,7 +33,6 @@ inline Int msb2(Int value) } int_with_msb; Int sint; } SInt; - SInt sint = {.sint = value}; return sint.int_with_msb.signal; }; @@ -52,13 +53,13 @@ Float BMath::Math::abs(Float value) }; template <> -Int BMath::Math::min(Int a,Int b) +Int BMath::Math::min(Int a, Int b) { - return b + ((a-b) & msb2(a-b)); + return b + ((a - b) & msb2(a - b)); } template <> -Int BMath::Math::max(Int a,Int b) +Int BMath::Math::max(Int a, Int b) { - return a + ((b-a) & ~msb2(b-a)); + return a + ((b - a) & ~msb2(b - a)); }