From 6632d045286b42d257eb3783e96256c13b588186 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 23 Aug 2024 22:26:43 -0400 Subject: [PATCH] fix to rounding func --- CMakeLists.txt | 2 +- include/blt/math/math.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df01084..5f1374d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) 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_TARGET BLT) diff --git a/include/blt/math/math.h b/include/blt/math/math.h index 32041b2..c6588e3 100644 --- a/include/blt/math/math.h +++ b/include/blt/math/math.h @@ -77,10 +77,10 @@ namespace blt else { constexpr double multiplier = pow(10.0, decimal_places); - auto i_value = static_cast(value); - auto f_value = value - static_cast(i_value); + auto i_value = static_cast(value * multiplier); + auto f_value = (value * multiplier) - static_cast(i_value); if (f_value > 0) - return ((static_cast(i_value) * multiplier + 1) / multiplier); + return ((static_cast(i_value) + 1) / multiplier); else return static_cast(i_value); }