Skip to content

Commit

Permalink
compiler fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravenwater committed Nov 11, 2024
1 parent 0598fdc commit 54b8bd6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
12 changes: 8 additions & 4 deletions include/universal/number/efloat/efloat_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,20 @@ class efloat {
private:

// efloat - efloat logic comparisons
friend bool operator==(const efloat& lhs, const efloat& rhs);
template<unsigned nlimbs>
friend bool operator==(const efloat<nlimbs>& lhs, const efloat<nlimbs>& rhs);

// efloat - literal logic comparisons
friend bool operator==(const efloat& lhs, const long long rhs);
template<unsigned nlimbs>
friend bool operator==(const efloat<nlimbs>& lhs, long long rhs);

// literal - efloat logic comparisons
friend bool operator==(const long long lhs, const efloat& rhs);
template<unsigned nlimbs>
friend bool operator==(long long lhs, const efloat<nlimbs>& rhs);

// find the most significant bit set
friend signed findMsb(const efloat& v);
template<unsigned nlimbs>
friend signed findMsb(const efloat<nlimbs>& v);
};

////////////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 4 additions & 3 deletions include/universal/number/erational/erational_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class erational {
erational& operator=(erational&&) = default;

erational(std::int64_t n, std::uint64_t d) : negative{ false }, numerator { n }, denominator{ d } {
negative = (n < 0 ^ d < 0);
negative = ((n < 0) ^ (d < 0));
}

// initializers for native types
Expand Down Expand Up @@ -182,16 +182,17 @@ class erational {

// selectors
bool iszero() const noexcept { return numerator.iszero(); }
bool sign() const noexcept { return negative; }
bool isneg() const noexcept { return negative; } // < 0
bool ispos() const noexcept { return !negative; } // >= 0
bool isinf() const noexcept { return false; }
bool isnan() const noexcept { return numerator.iszero() && denominator.iszero(); }
bool sign() const noexcept { return negative; }
edecimal top() const noexcept { return numerator; }
edecimal bottom() const noexcept { return denominator; }
std::pair<int64_t, int64_t> toPair() const noexcept {
return { int64_t(numerator), int64_t(denominator) };
}


// modifiers
void setzero() {
negative = false;
Expand Down
6 changes: 3 additions & 3 deletions include/universal/number/erational/math/classify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace sw { namespace universal {

// STD LIB function for IEEE floats: Categorizes floating point value arg into the following categories: zero, subnormal, normal, infinite, NAN, or implementation-defined category.
int fpclassify(const erational& a) {
return std::fpclassify((long double)(a));
return std::fpclassify(double(a));
}

// STD LIB function for IEEE floats: Determines if the given floating point number arg has finite value i.e. it is normal, subnormal or zero, but not infinite or NaN.
Expand All @@ -28,13 +28,13 @@ namespace sw { namespace universal {
// STD LIB function for IEEE floats: Determines if the given floating point number arg is a not-a-number (NaN) value.
// specialized for erationals
inline bool isnan(const erational& a) {
return false;
return a.isnan();
}

// STD LIB function for IEEE floats: Determines if the given floating point number arg is normal, i.e. is neither zero, subnormal, infinite, nor NaN.
// specialized for erationals
inline bool isnormal(const erational& a) {
return true;
return !a.isnan();
}

}} // namespace sw::universal
2 changes: 0 additions & 2 deletions include/universal/number/rational/attributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ bool sign(const rational<nbits,bt>& v) {
// the type of arithmetic, Modulo or Saturating, does not affect the range
template<unsigned nbits, typename bt>
std::string rational_range(const rational<nbits,bt>& r) {
using Rational = rational<nbits,bt>;
std::stringstream s;
Rational r;
s << std::setw(45) << type_tag(r) << " : [ "
<< r.maxneg() << " ... "
<< r.minneg() << " "
Expand Down
2 changes: 0 additions & 2 deletions include/universal/number/rational/rational_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ class rational {
SignedBlockBinary numerator() const noexcept { return n; }
SignedBlockBinary denominator() const noexcept { return d; }



protected:
// HELPER methods

Expand Down

0 comments on commit 54b8bd6

Please sign in to comment.