mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
AK: Format floats with precision in scientific notation where applicable
This commit is contained in:
parent
1474da31c7
commit
861bcbd9ad
Notes:
github-actions[bot]
2025-08-11 16:11:59 +00:00
Author: https://github.com/Calme1709
Commit: 861bcbd9ad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5734
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/tcl3
2 changed files with 75 additions and 54 deletions
|
|
@ -267,6 +267,12 @@ TEST_CASE(floating_point_numbers)
|
|||
EXPECT_EQ(ByteString::formatted("{:'.4}", 1234.5678), "1,234.5678");
|
||||
EXPECT_EQ(ByteString::formatted("{:'.4}", -1234.5678), "-1,234.5678");
|
||||
|
||||
EXPECT_EQ(ByteString::formatted("{:.5}", 1.2345678e-15), "1.23456e-15");
|
||||
EXPECT_EQ(ByteString::formatted("{:.5}", AK::NumericLimits<float>::max()), "3.40282e+38");
|
||||
EXPECT_EQ(ByteString::formatted("{:.5}", AK::NumericLimits<float>::lowest()), "-3.40282e+38");
|
||||
EXPECT_EQ(ByteString::formatted("{:.5}", 3.000001e30), "3e+30");
|
||||
EXPECT_EQ(ByteString::formatted("{:.5}", 3.1e30), "3.1e+30");
|
||||
|
||||
EXPECT_EQ(ByteString::formatted("{:.30f}", 1.0), "1.000000000000000000000000000000");
|
||||
EXPECT_EQ(ByteString::formatted("{:.30f}", 1.5), "1.500000000000000000000000000000");
|
||||
EXPECT_EQ(ByteString::formatted("{:.30f}", -2.0), "-2.000000000000000000000000000000");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue