You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
template<typename Dec>
void mixed_compare()
{
std::print("{}\n", boost::typeindex::type_id<Dec>().pretty_name());
const Dec a{2, 1};
const auto b = __uint128_t{std::numeric_limits<__uint128_t>::max() - std::numeric_limits<uint64_t>::max() + 20};
std::print("a:{:.30e}\nb:{}\n", a , b);
std::print("same {} \n\n", a == b );
}
on my machine prints
boost::decimal::decimal32
a:2.000000000000000000000000000000e+01
b:340282366920938463444927863358058659860
same true
boost::decimal::decimal64
a:2.000000000000000000000000000000e+01
b:340282366920938463444927863358058659860
same true
boost::decimal::decimal128
a:2.000000000000000000000000000000e+01
b:340282366920938463444927863358058659860
same false
I guess it is clear from test construction what I think the bug is(truncation). _fast code works fine for all sizes(probably because it dispatches to different equal_parts_impl).
edit:
For decimal32 bug persists if we "halve" the types used in b
const auto b = uint64_t{std::numeric_limits<uint64_t>::max() - std::numeric_limits<uint32_t>::max() + 20};
The text was updated successfully, but these errors were encountered:
libbooze
changed the title
Incorrect == with __uint128t
Incorrect == with __uint128t/uint64_t
Jan 18, 2025
We didn't design or test for math against non-standard extensions like __uint128_t. Really the only functionality that exists for them is conversion from or too. In the uint64_t case there's likely narrowing somewhere. It works in the decimal32_fast case because I'm willing to bet that your machine has uint_fast32_t as uint64_t
Following code:
on my machine prints
I guess it is clear from test construction what I think the bug is(truncation). _fast code works fine for all sizes(probably because it dispatches to different
equal_parts_impl
).edit:
For decimal32 bug persists if we "halve" the types used in b
The text was updated successfully, but these errors were encountered: