mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 16:57:36 +00:00
AK: Add support for keeping trailing zeros in fixed precision floats
This uses the same syntax as zero padding integers: String::formatted("{:0.5}", 1.234) => "1.23400"
This commit is contained in:
parent
4d5ffd364a
commit
5e53a690ac
3 changed files with 15 additions and 3 deletions
|
@ -252,6 +252,12 @@ TEST_CASE(yay_this_implementation_sucks)
|
|||
EXPECT_EQ(String::formatted("{:.0}", .99999999999), "0");
|
||||
}
|
||||
|
||||
TEST_CASE(precision_with_trailing_zeros)
|
||||
{
|
||||
EXPECT_EQ(String::formatted("{:0.3}", 1.12), "1.120");
|
||||
EXPECT_EQ(String::formatted("{:0.1}", 1.12), "1.1");
|
||||
}
|
||||
|
||||
TEST_CASE(magnitude_less_than_zero)
|
||||
{
|
||||
EXPECT_EQ(String::formatted("{}", -0.654), "-0.654");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue