mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 21:33:59 +00:00
Removed SignedRound and replaced std::round with std::lround where needed
Also see https://clang.llvm.org/extra/clang-tidy/checks/bugprone/incorrect-roundings.html Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
committed by
Konstantin Pastbin
parent
ae349462c6
commit
76d7ef146c
@@ -113,7 +113,7 @@ std::string FormatLatLonAsDMSImpl(double value, char positive, char negative, in
|
||||
// Seconds
|
||||
d = d * 60.0;
|
||||
if (dac == 0)
|
||||
d = math::SignedRound(d);
|
||||
d = std::round(d);
|
||||
|
||||
d = std::modf(d, &i);
|
||||
sstream << std::setw(2) << i;
|
||||
@@ -124,7 +124,7 @@ std::string FormatLatLonAsDMSImpl(double value, char positive, char negative, in
|
||||
sstream << "″";
|
||||
|
||||
// This condition is too heavy for production purposes (but more correct).
|
||||
//if (math::SignedRound(value * 3600.0 * pow(10, dac)) != 0)
|
||||
//if (std::round(value * 3600.0 * pow(10, dac)) != 0)
|
||||
if (!AlmostEqualULPs(value, 0.0))
|
||||
{
|
||||
char postfix = positive;
|
||||
@@ -200,7 +200,7 @@ double MpsToUnits(double metersPerSecond, Units units)
|
||||
|
||||
int FormatSpeed(double metersPerSecond, Units units)
|
||||
{
|
||||
return static_cast<int>(std::round(MpsToUnits(metersPerSecond, units)));
|
||||
return std::lround(MpsToUnits(metersPerSecond, units));
|
||||
}
|
||||
|
||||
std::string FormatSpeedNumeric(double metersPerSecond, Units units)
|
||||
@@ -214,8 +214,8 @@ std::string FormatOsmLink(double lat, double lon, int zoom)
|
||||
|
||||
// Same as (lon + 180) / 360 * 1UL << 32, but without warnings.
|
||||
double constexpr factor = (1 << 30) / 90.0;
|
||||
uint32_t const x = round((lon + 180.0) * factor);
|
||||
uint32_t const y = round((lat + 90.0) * factor * 2.0);
|
||||
uint32_t const x = std::lround((lon + 180.0) * factor);
|
||||
uint32_t const y = std::lround((lat + 90.0) * factor * 2.0);
|
||||
uint64_t const code = bits::BitwiseMerge(y, x);
|
||||
std::string osmUrl = "https://osm.org/go/";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user