From 2d695e3c7c132231ab701a70ce7e72a6e8cde887 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 4 May 2019 21:24:17 -0400 Subject: [PATCH] common/fp/info: Make formatting of FPInfo struct member functions consistent Orgranizes the functions to all be consistent with the half-precision specialization. --- src/common/fp/info.h | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/common/fp/info.h b/src/common/fp/info.h index d60c4a31..d3cb436c 100644 --- a/src/common/fp/info.h +++ b/src/common/fp/info.h @@ -65,10 +65,21 @@ struct FPInfo { static constexpr int exponent_max = 127; static constexpr int exponent_bias = 127; - static constexpr u32 Zero(bool sign) { return sign ? sign_mask : 0; } - static constexpr u32 Infinity(bool sign) { return exponent_mask | Zero(sign); } - static constexpr u32 MaxNormal(bool sign) { return (exponent_mask - 1) | Zero(sign); } - static constexpr u32 DefaultNaN() { return exponent_mask | (u32(1) << (explicit_mantissa_width - 1)); } + static constexpr u32 Zero(bool sign) { + return sign ? sign_mask : 0; + } + + static constexpr u32 Infinity(bool sign) { + return exponent_mask | Zero(sign); + } + + static constexpr u32 MaxNormal(bool sign) { + return (exponent_mask - 1) | Zero(sign); + } + + static constexpr u32 DefaultNaN() { + return exponent_mask | (u32(1) << (explicit_mantissa_width - 1)); + } }; template<> @@ -88,10 +99,21 @@ struct FPInfo { static constexpr int exponent_max = 1023; static constexpr int exponent_bias = 1023; - static constexpr u64 Zero(bool sign) { return sign ? sign_mask : 0; } - static constexpr u64 Infinity(bool sign) { return exponent_mask | Zero(sign); } - static constexpr u64 MaxNormal(bool sign) { return (exponent_mask - 1) | Zero(sign); } - static constexpr u64 DefaultNaN() { return exponent_mask | (u64(1) << (explicit_mantissa_width - 1)); } + static constexpr u64 Zero(bool sign) { + return sign ? sign_mask : 0; + } + + static constexpr u64 Infinity(bool sign) { + return exponent_mask | Zero(sign); + } + + static constexpr u64 MaxNormal(bool sign) { + return (exponent_mask - 1) | Zero(sign); + } + + static constexpr u64 DefaultNaN() { + return exponent_mask | (u64(1) << (explicit_mantissa_width - 1)); + } }; /// value = (sign ? -1 : +1) * 2^exponent * value