return std::make_pair(Digits, Scale);
}
+/// \brief Convenience helper for 32-bit rounding.
+inline std::pair<uint32_t, int16_t> getRounded32(uint32_t Digits, int16_t Scale,
+ bool ShouldRound) {
+ return getRounded(Digits, Scale, ShouldRound);
+}
+
+/// \brief Convenience helper for 64-bit rounding.
+inline std::pair<uint64_t, int16_t> getRounded64(uint64_t Digits, int16_t Scale,
+ bool ShouldRound) {
+ return getRounded(Digits, Scale, ShouldRound);
+}
+
/// \brief Adjust a 64-bit scaled number down to the appropriate width.
///
/// Adjust a soft float with 64-bits of digits down, keeping as much
typedef ScaledPair<uint64_t> SP64;
TEST(ScaledNumberHelpersTest, getRounded) {
- EXPECT_EQ(getRounded<uint32_t>(0, 0, false), SP32(0, 0));
- EXPECT_EQ(getRounded<uint32_t>(0, 0, true), SP32(1, 0));
- EXPECT_EQ(getRounded<uint32_t>(20, 21, true), SP32(21, 21));
- EXPECT_EQ(getRounded<uint32_t>(UINT32_MAX, 0, false), SP32(UINT32_MAX, 0));
- EXPECT_EQ(getRounded<uint32_t>(UINT32_MAX, 0, true), SP32(1 << 31, 1));
+ EXPECT_EQ(getRounded32(0, 0, false), SP32(0, 0));
+ EXPECT_EQ(getRounded32(0, 0, true), SP32(1, 0));
+ EXPECT_EQ(getRounded32(20, 21, true), SP32(21, 21));
+ EXPECT_EQ(getRounded32(UINT32_MAX, 0, false), SP32(UINT32_MAX, 0));
+ EXPECT_EQ(getRounded32(UINT32_MAX, 0, true), SP32(1 << 31, 1));
- EXPECT_EQ(getRounded<uint64_t>(0, 0, false), SP64(0, 0));
- EXPECT_EQ(getRounded<uint64_t>(0, 0, true), SP64(1, 0));
- EXPECT_EQ(getRounded<uint64_t>(20, 21, true), SP64(21, 21));
- EXPECT_EQ(getRounded<uint64_t>(UINT32_MAX, 0, false), SP64(UINT32_MAX, 0));
- EXPECT_EQ(getRounded<uint64_t>(UINT32_MAX, 0, true),
- SP64(UINT64_C(1) << 32, 0));
- EXPECT_EQ(getRounded<uint64_t>(UINT64_MAX, 0, false), SP64(UINT64_MAX, 0));
- EXPECT_EQ(getRounded<uint64_t>(UINT64_MAX, 0, true),
- SP64(UINT64_C(1) << 63, 1));
+ EXPECT_EQ(getRounded64(0, 0, false), SP64(0, 0));
+ EXPECT_EQ(getRounded64(0, 0, true), SP64(1, 0));
+ EXPECT_EQ(getRounded64(20, 21, true), SP64(21, 21));
+ EXPECT_EQ(getRounded64(UINT32_MAX, 0, false), SP64(UINT32_MAX, 0));
+ EXPECT_EQ(getRounded64(UINT32_MAX, 0, true), SP64(UINT64_C(1) << 32, 0));
+ EXPECT_EQ(getRounded64(UINT64_MAX, 0, false), SP64(UINT64_MAX, 0));
+ EXPECT_EQ(getRounded64(UINT64_MAX, 0, true), SP64(UINT64_C(1) << 63, 1));
}
TEST(FloatsTest, getAdjusted) {