1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:47:35 +00:00
serenity/Userland
Daniel Bertalan c6fafd3e90 AK+Userland: Add generic AK::abs() function and use it
Previously, in LibGFX's `Point` class, calculated distances were passed
to the integer `abs` function, even if the stored type was a float. This
caused the value to unexpectedly be truncated. Luckily, this API was not
used with floating point types, but that can change in the future, so
why not fix it now :^)

Since we are in C++, we can use function overloading to make things
easy, and to automatically use the right version.

This is even better than the LibC/LibM functions, as using a bit of
hackery, they are able to be constant-evaluated. They use compiler
intrinsics, so they do not depend on external code and the compiler can
emit the most optimized code by default.

Since we aren't using the C++ standard library's trick of importing
everything into the `AK` namespace, this `abs` function cannot be
exported to the global namespace, as the names would clash.
2021-07-08 10:11:00 +02:00
..
Applets Everywhere: Add component declarations 2021-06-17 11:03:51 +02:00
Applications Everywhere: Remove unused local variables and lambda captures 2021-07-08 10:11:00 +02:00
Demos AK+Userland: Add generic AK::abs() function and use it 2021-07-08 10:11:00 +02:00
DevTools Everywhere: Remove unused local variables and lambda captures 2021-07-08 10:11:00 +02:00
DynamicLoader DynamicLoader: Don't use LibELF to do the initial relocations 2021-07-07 11:53:17 +02:00
Games GameOfLife: Properly switch between play and pause icon 2021-07-07 15:29:37 +01:00
Libraries AK+Userland: Add generic AK::abs() function and use it 2021-07-08 10:11:00 +02:00
Services WindowServer: Don't use old GNU-style designator 2021-07-08 10:11:00 +02:00
Shell Everywhere: Prefer using "..."sv over StringView { "..." } 2021-07-04 14:24:03 +02:00
Utilities WindowServer+wsctl: Add a simple utility for toggling "flash flush" 2021-07-07 22:56:46 +02:00
CMakeLists.txt Tests: Establish root Tests directory, move Userland/Tests there 2021-05-06 17:54:28 +02:00