mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00:00
AK: Refactor FixedPoint's formatter
The main change is the simplification of the expression `(10^precision * fraction) / 2^precision` to `5^precision * fraction`. Those expressions overflow or not depends on the value of `precision` and `fraction`. For the maximum value of `fraction`, the following table shows for which value of `precision` overflow will occur. Old New u32 08 10 u64 15 20 u128 30 39 As of now `u64` type is used to calculate the result of the expression. Meaning that before, only FixedPoints with `precision` less than 15 could be accurately rendered (for every value of fraction) in decimal. Now, this limit gets increased to 20. This refactor also fixes, broken decimal render for explicitly specified precision width in format string, and broken hexadecimal render.
This commit is contained in:
parent
d40807681d
commit
352480338e
4 changed files with 147 additions and 53 deletions
|
@ -214,16 +214,16 @@ public:
|
|||
i64 integer_value,
|
||||
u64 fraction_value,
|
||||
u64 fraction_one,
|
||||
size_t precision,
|
||||
u8 base = 10,
|
||||
bool upper_case = false,
|
||||
bool zero_pad = false,
|
||||
bool use_separator = false,
|
||||
Align align = Align::Right,
|
||||
size_t min_width = 0,
|
||||
size_t precision = 6,
|
||||
size_t fraction_max_width = 6,
|
||||
char fill = ' ',
|
||||
SignMode sign_mode = SignMode::OnlyIfNeeded,
|
||||
RealNumberDisplayMode = RealNumberDisplayMode::Default);
|
||||
SignMode sign_mode = SignMode::OnlyIfNeeded);
|
||||
|
||||
#ifndef KERNEL
|
||||
ErrorOr<void> put_f80(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue