mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
Userland: Use AK::pow<I> where applicable
This commit is contained in:
parent
9ba9691d19
commit
3e135f347f
3 changed files with 14 additions and 11 deletions
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "Keypad.h"
|
#include "Keypad.h"
|
||||||
#include "KeypadValue.h"
|
#include "KeypadValue.h"
|
||||||
#include <AK/Math.h>
|
#include <AK/IntegralMath.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
|
||||||
Keypad::Keypad()
|
Keypad::Keypad()
|
||||||
|
@ -119,8 +119,8 @@ void Keypad::set_value(KeypadValue value)
|
||||||
} else
|
} else
|
||||||
m_negative = false;
|
m_negative = false;
|
||||||
|
|
||||||
m_int_value = value.m_value / (u64)AK::pow(10.0, (double)value.m_decimal_places);
|
m_int_value = value.m_value / AK::pow<u64>(10, value.m_decimal_places);
|
||||||
m_frac_value = value.m_value % (u64)AK::pow(10.0, (double)value.m_decimal_places);
|
m_frac_value = value.m_value % AK::pow<u64>(10, value.m_decimal_places);
|
||||||
m_frac_length = value.m_decimal_places;
|
m_frac_length = value.m_decimal_places;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "KeypadValue.h"
|
#include "KeypadValue.h"
|
||||||
|
#include <AK/IntegralMath.h>
|
||||||
#include <AK/Math.h>
|
#include <AK/Math.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ ALWAYS_INLINE T KeypadValue::operator_helper(KeypadValue const& lhs, KeypadValue
|
||||||
KeypadValue const& more_decimal_places = (lhs.m_decimal_places < rhs.m_decimal_places) ? rhs : lhs;
|
KeypadValue const& more_decimal_places = (lhs.m_decimal_places < rhs.m_decimal_places) ? rhs : lhs;
|
||||||
|
|
||||||
i64 more_decimal_places_equalized = more_decimal_places.m_value;
|
i64 more_decimal_places_equalized = more_decimal_places.m_value;
|
||||||
i64 less_decimal_places_equalized = (i64)AK::pow(10.0, (double)(more_decimal_places.m_decimal_places - less_decimal_places.m_decimal_places)) * less_decimal_places.m_value;
|
i64 less_decimal_places_equalized = AK::pow<i64>(10, more_decimal_places.m_decimal_places - less_decimal_places.m_decimal_places) * less_decimal_places.m_value;
|
||||||
|
|
||||||
bool lhs_is_less = (lhs.m_decimal_places < rhs.m_decimal_places);
|
bool lhs_is_less = (lhs.m_decimal_places < rhs.m_decimal_places);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "Tools/MoveTool.h"
|
#include "Tools/MoveTool.h"
|
||||||
#include "Tools/Tool.h"
|
#include "Tools/Tool.h"
|
||||||
|
#include <AK/IntegralMath.h>
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <LibConfig/Client.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibFileSystemAccessClient/Client.h>
|
#include <LibFileSystemAccessClient/Client.h>
|
||||||
|
@ -218,14 +219,15 @@ int ImageEditor::calculate_ruler_step_size() const
|
||||||
const auto step_target = 80 / scale();
|
const auto step_target = 80 / scale();
|
||||||
const auto max_factor = 5;
|
const auto max_factor = 5;
|
||||||
for (int factor = 0; factor < max_factor; ++factor) {
|
for (int factor = 0; factor < max_factor; ++factor) {
|
||||||
if (step_target <= 1 * (float)pow(10, factor))
|
int ten_to_factor = AK::pow<int>(10, factor);
|
||||||
return 1 * pow(10, factor);
|
if (step_target <= 1 * ten_to_factor)
|
||||||
if (step_target <= 2 * (float)pow(10, factor))
|
return 1 * ten_to_factor;
|
||||||
return 2 * pow(10, factor);
|
if (step_target <= 2 * ten_to_factor)
|
||||||
if (step_target <= 5 * (float)pow(10, factor))
|
return 2 * ten_to_factor;
|
||||||
return 5 * pow(10, factor);
|
if (step_target <= 5 * ten_to_factor)
|
||||||
|
return 5 * ten_to_factor;
|
||||||
}
|
}
|
||||||
return 1 * pow(10, max_factor);
|
return AK::pow<int>(10, max_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::IntRect ImageEditor::mouse_indicator_rect_x() const
|
Gfx::IntRect ImageEditor::mouse_indicator_rect_x() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue