mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
Everywhere: Use the correct literal suffixes
When performing arithmetic with long doubles/floats, we want to avoid floating point promotion and narrowing.
This commit is contained in:
parent
b76ad3db90
commit
714bd011e1
2 changed files with 7 additions and 7 deletions
|
@ -394,7 +394,7 @@ void FormatBuilder::put_f80(
|
||||||
StringBuilder string_builder;
|
StringBuilder string_builder;
|
||||||
FormatBuilder format_builder { string_builder };
|
FormatBuilder format_builder { string_builder };
|
||||||
|
|
||||||
bool is_negative = value < 0.0;
|
bool is_negative = value < 0.0l;
|
||||||
if (is_negative)
|
if (is_negative)
|
||||||
value = -value;
|
value = -value;
|
||||||
|
|
||||||
|
@ -406,16 +406,16 @@ void FormatBuilder::put_f80(
|
||||||
// https://youtu.be/4P_kbF0EbZM (Stephan T. Lavavej “Floating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss”)
|
// https://youtu.be/4P_kbF0EbZM (Stephan T. Lavavej “Floating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss”)
|
||||||
value -= static_cast<i64>(value);
|
value -= static_cast<i64>(value);
|
||||||
|
|
||||||
long double epsilon = 0.5;
|
long double epsilon = 0.5l;
|
||||||
for (size_t i = 0; i < precision; ++i)
|
for (size_t i = 0; i < precision; ++i)
|
||||||
epsilon /= 10.0;
|
epsilon /= 10.0l;
|
||||||
|
|
||||||
size_t visible_precision = 0;
|
size_t visible_precision = 0;
|
||||||
for (; visible_precision < precision; ++visible_precision) {
|
for (; visible_precision < precision; ++visible_precision) {
|
||||||
if (value - static_cast<i64>(value) < epsilon)
|
if (value - static_cast<i64>(value) < epsilon)
|
||||||
break;
|
break;
|
||||||
value *= 10.0;
|
value *= 10.0l;
|
||||||
epsilon *= 10.0;
|
epsilon *= 10.0l;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visible_precision > 0) {
|
if (visible_precision > 0) {
|
||||||
|
|
|
@ -465,9 +465,9 @@ void ColorField::create_color_bitmap()
|
||||||
Gfx::HSV hsv;
|
Gfx::HSV hsv;
|
||||||
hsv.hue = m_hue;
|
hsv.hue = m_hue;
|
||||||
for (int x = 0; x < 256; x++) {
|
for (int x = 0; x < 256; x++) {
|
||||||
hsv.saturation = x / 255.0f;
|
hsv.saturation = x / 255.0;
|
||||||
for (int y = 0; y < 256; y++) {
|
for (int y = 0; y < 256; y++) {
|
||||||
hsv.value = (255 - y) / 255.0f;
|
hsv.value = (255 - y) / 255.0;
|
||||||
Color color = Color::from_hsv(hsv);
|
Color color = Color::from_hsv(hsv);
|
||||||
painter.set_pixel({ x, y }, color);
|
painter.set_pixel({ x, y }, color);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue