mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +00:00
AK: Fix incorrect formatter signing of numbers between -1.0 and 0.0
Floating point numbers are casted to i64 and passed to the integer formatting logic, and the floating point portion of the number is handled separately. However, casting to i64 when the number is between -1.0 and 0.0 produces 0, so the sign would be lost. This commit fixes that by using put_u64 instead, which allows us to manually provide the is_negative flag.
This commit is contained in:
parent
bf8223926a
commit
d719e745fb
2 changed files with 11 additions and 4 deletions
|
@ -273,6 +273,12 @@ TEST_CASE(yay_this_implementation_sucks)
|
|||
EXPECT_EQ(String::formatted("{:.0}", .99999999999), "0");
|
||||
}
|
||||
|
||||
TEST_CASE(magnitude_less_than_zero)
|
||||
{
|
||||
EXPECT_EQ(String::formatted("{}", -0.654), "-0.654");
|
||||
EXPECT_EQ(String::formatted("{}", 0.654), "0.654");
|
||||
}
|
||||
|
||||
TEST_CASE(format_nullptr)
|
||||
{
|
||||
EXPECT_EQ(String::formatted("{}", nullptr), String::formatted("{:p}", static_cast<FlatPtr>(0)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue