1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:47:35 +00:00

AK: Fix FixedPoint multiplication rounding and overflow behaviour

We now preform the multiplication in a widened type which makes it
overflow-safe and use the correct bit for rounding direction detection.
This commit is contained in:
Hendiadyoin1 2023-07-23 19:42:19 +02:00 committed by Andrew Kaster
parent 32de3ddd33
commit e609ac74a3
2 changed files with 21 additions and 23 deletions

View file

@ -26,6 +26,11 @@ TEST_CASE(arithmetic)
EXPECT_EQ(
Type((int)1) * Type(0.5),
Type(0.5));
EXPECT_EQ(Type(0.125) * Type(3.75),
Type(0.125 * 3.75));
EXPECT_EQ(Type(0.125) * Type(-3.75),
Type(0.125 * -3.75));
EXPECT_EQ(
Type((int)1) / Type(0.5),
Type(2));