Skip to content

Commit

Permalink
Syntax and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Kormanyos committed Jun 10, 2024
1 parent 13bfcb4 commit 0c07ce0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions math/wide_decimal/decwide_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,15 +612,14 @@
// Emphasize: This template class can be used with native
// floating-point types like float, double and long double.

// Note: For long double, you need to verify that the
// mantissa fits in unsigned long long.

explicit native_float_parts(FloatingPointType f)
{
using native_float_type = FloatingPointType;

static_assert(std::numeric_limits<native_float_type>::digits <= std::numeric_limits<unsigned long long>::digits, // NOLINT(google-runtime-int)
"Error: The width of the mantissa does not fit in unsigned long long");
// For long double, verify that the mantissa fits in std::uintmax_t.

static_assert(std::numeric_limits<native_float_type>::digits <= std::numeric_limits<std::uintmax_t>::digits,
"Error: The width of the mantissa does not fit in std::uintmax_t");

const native_float_type ff = ((f < static_cast<native_float_type>(0)) ? static_cast<native_float_type>(-f) : f);

Expand All @@ -646,7 +645,8 @@
++i)
{
// Extract the mantissa of the floating-point type in base-2
// (one bit at a time) and store it in an unsigned long long.
// (one bit at a time) and store it in a std::uintmax_t.

man *= 2;

n2 = static_cast<unsigned>(man);
Expand Down Expand Up @@ -676,7 +676,7 @@
: std::numeric_limits<long double>::digits
);

my_mantissa_part |= static_cast<unsigned long long>(1ULL << static_cast<unsigned>(max_left_shift_amount - 1)); // NOLINT(google-runtime-int)
my_mantissa_part |= static_cast<std::uintmax_t>(UINTMAX_C(1) << static_cast<unsigned>(max_left_shift_amount - 1)); // NOLINT(google-runtime-int)
my_exponent_part -= 1;
}

Expand Down Expand Up @@ -711,12 +711,12 @@
return *this;
}

WIDE_DECIMAL_NODISCARD constexpr auto get_mantissa() const noexcept -> unsigned long long { return my_mantissa_part; } // NOLINT(google-runtime-int)
WIDE_DECIMAL_NODISCARD constexpr auto get_exponent() const noexcept -> int { return my_exponent_part; }
WIDE_DECIMAL_NODISCARD constexpr auto get_mantissa() const noexcept -> std::uintmax_t { return my_mantissa_part; }
WIDE_DECIMAL_NODISCARD constexpr auto get_exponent() const noexcept -> int { return my_exponent_part; }

private:
unsigned long long my_mantissa_part { }; // NOLINT(readability-identifier-naming,google-runtime-int)
int my_exponent_part { }; // NOLINT(readability-identifier-naming)
std::uintmax_t my_mantissa_part { }; // NOLINT(readability-identifier-naming)
int my_exponent_part { }; // NOLINT(readability-identifier-naming)
};

#if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS)
Expand Down
4 changes: 2 additions & 2 deletions wide_decimal.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='wide-decimal-debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir);C:\boost\boost_1_83_0;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir);C:\boost\boost_1_85_0;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>$(OutDir)</IntDir>
<TargetName>$(Configuration)-$(PlatformTarget)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='wide-decimal-release|x64'">
<IncludePath>$(SolutionDir);C:\boost\boost_1_83_0;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir);C:\boost\boost_1_85_0;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>$(OutDir)</IntDir>
<TargetName>$(Configuration)-$(PlatformTarget)</TargetName>
Expand Down
8 changes: 4 additions & 4 deletions wide_decimal_vs2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='wide-decimal-debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='wide-decimal-release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand All @@ -45,14 +45,14 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='wide-decimal-debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir);C:\boost\boost_1_83_0;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir);C:\boost\boost_1_85_0;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>$(OutDir)</IntDir>
<TargetName>$(Configuration)-$(PlatformTarget)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='wide-decimal-release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir);C:\boost\boost_1_83_0;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir);C:\boost\boost_1_85_0;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>$(OutDir)</IntDir>
<TargetName>$(Configuration)-$(PlatformTarget)</TargetName>
Expand Down

0 comments on commit 0c07ce0

Please sign in to comment.