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:
parent
32de3ddd33
commit
e609ac74a3
2 changed files with 21 additions and 23 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue