Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Mar 12, 2024
1 parent a4f2b36 commit dcca178
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_ID STREQUAL GNU)
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
-Wall -Wextra -Wpedantic -Wconversion -Werror=return-type
)
# TODO: Remove this later.
# Some variables have been provided but are not currently being used, but it would not atm make sense to remove them.
# So to clean up the warnings we are just silencing these specific cases.
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
-Wno-unused-but-set-variable -Wno-unused-value
)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
Expand Down
10 changes: 4 additions & 6 deletions include/ccmath/detail/exponential/details/log2_double_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@ namespace ccm::internal
ccm::double_t logExpoSum{};
ccm::double_t polynomialTerm{};

std::uint64_t intX{};
std::uint64_t intNorm{};
std::uint64_t tmp{};

std::uint32_t top{};

int expo{};
int i{};
std::int64_t expo{};
std::int64_t i{};

intX = ccm::helpers::double_to_uint64(x);
top = ccm::helpers::top16_bits_of_double(x);
std::uint64_t intX = ccm::helpers::double_to_uint64(x);
std::uint32_t top = ccm::helpers::top16_bits_of_double(x);

constexpr std::uint64_t low = ccm::helpers::double_to_uint64(1.0 - 0x1.5b51p-5);
constexpr std::uint64_t high = ccm::helpers::double_to_uint64(1.0 + 0x1.6ab2p-5);
Expand Down
10 changes: 4 additions & 6 deletions include/ccmath/detail/exponential/details/log_double_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,16 @@ namespace ccm::internal
ccm::double_t lowPart{};

// Declare variables for bitwise operations
std::uint64_t intX{};
std::uint64_t intNorm{};
std::uint64_t tmp{};
std::uint32_t top{};

// Declare variables for exponent and loop iteration
int expo{};
int i{};
std::int64_t expo{};
std::int64_t i{};

// Convert input double to uint64_t and extract top 16 bits
intX = ccm::helpers::double_to_uint64(x);
top = ccm::helpers::top16_bits_of_double(x);
std::uint64_t intX = ccm::helpers::double_to_uint64(x);
std::uint32_t top = ccm::helpers::top16_bits_of_double(x);

// Constants for comparison
constexpr std::uint64_t low = ccm::helpers::double_to_uint64(1.0 - 0x1p-4);
Expand Down
4 changes: 2 additions & 2 deletions include/ccmath/internal/helpers/bits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ namespace ccm::helpers
*/
inline constexpr std::uint32_t top16_bits_of_double(double x) noexcept
{
return bit_cast<std::uint64_t>(x) >> 48;
return static_cast<std::uint32_t>(bit_cast<std::uint64_t>(x) >> 48);
}

inline constexpr std::uint32_t top12_bits_of_double(double x) noexcept
{
return bit_cast<std::uint64_t>(x) >> 52;
return static_cast<std::uint32_t>(bit_cast<std::uint64_t>(x) >> 52);
}

inline constexpr std::uint64_t double_to_uint64(double x) noexcept
Expand Down
1 change: 1 addition & 0 deletions test/ccmath_test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <gtest/gtest.h>
#include "ccmath/ccmath.hpp"


int main(int argc, char** argv)
Expand Down

0 comments on commit dcca178

Please sign in to comment.