-
-
Notifications
You must be signed in to change notification settings - Fork 954
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utility: Add function for calculating a rounded division
Make weather service use it.
- Loading branch information
1 parent
5705fad
commit 4a13235
Showing
2 changed files
with
8 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <concepts> | ||
|
||
namespace Pinetime { | ||
namespace Utility { | ||
// returns the arcsin of `arg`. asin(-32767) = -90, asin(32767) = 90 | ||
int16_t Asin(int16_t arg); | ||
|
||
static constexpr auto RoundedDiv(std::integral auto dividend, std::unsigned_integral auto divisor) -> decltype(dividend / divisor) { | ||
return (dividend + (dividend >= 0 ? divisor : -divisor) / 2) / divisor; | ||
} | ||
} | ||
} |