fix to rounding func

v1
Brett 2024-08-23 22:26:43 -04:00
parent 1b09483af0
commit 6632d04528
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 0.19.1) set(BLT_VERSION 0.19.2)
set(BLT_TEST_VERSION 0.0.1) set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -77,10 +77,10 @@ namespace blt
else else
{ {
constexpr double multiplier = pow(10.0, decimal_places); constexpr double multiplier = pow(10.0, decimal_places);
auto i_value = static_cast<blt::i64>(value); auto i_value = static_cast<blt::i64>(value * multiplier);
auto f_value = value - static_cast<double>(i_value); auto f_value = (value * multiplier) - static_cast<double>(i_value);
if (f_value > 0) if (f_value > 0)
return ((static_cast<double>(i_value) * multiplier + 1) / multiplier); return ((static_cast<double>(i_value) + 1) / multiplier);
else else
return static_cast<double>(i_value); return static_cast<double>(i_value);
} }