Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/s2/util/math/exactfloat/exactfloat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ ExactFloat::ExactFloat(double v) {
// by the number of mantissa bits in a double (53, including the leading
// "1") then the result is always an integer.
int exp;
double f = frexp(fabs(v), &exp);
uint64_t m = static_cast<uint64_t>(ldexp(f, kDoubleMantissaBits));
double f = std::frexp(std::fabs(v), &exp);
uint64_t m = static_cast<uint64_t>(std::ldexp(f, kDoubleMantissaBits));
BN_ext_set_uint64(bn_.get(), m);
bn_exp_ = exp - kDoubleMantissaBits;
Canonicalize();
Expand All @@ -163,7 +163,7 @@ ExactFloat::ExactFloat(int v) {
sign_ = (v >= 0) ? 1 : -1;
// Note that this works even for INT_MIN because the parameter type for
// BN_set_word() is unsigned.
ABSL_CHECK(BN_set_word(bn_.get(), abs(v)));
ABSL_CHECK(BN_set_word(bn_.get(), std::abs(v)));
bn_exp_ = 0;
Canonicalize();
}
Expand Down Expand Up @@ -239,7 +239,7 @@ ExactFloat::operator double() const {
double ExactFloat::ToDoubleHelper() const {
ABSL_DCHECK_LE(BN_num_bits(bn_.get()), kDoubleMantissaBits);
if (!isnormal(*this)) {
if (is_zero()) return copysign(0, sign_);
if (is_zero()) return std::copysign(0, sign_);
if (isinf(*this)) {
return std::copysign(std::numeric_limits<double>::infinity(), sign_);
}
Expand All @@ -248,7 +248,7 @@ double ExactFloat::ToDoubleHelper() const {
uint64_t d_mantissa = BN_ext_get_uint64(bn_.get());
// We rely on ldexp() to handle overflow and underflow. (It will return a
// signed zero or infinity if the result is too small or too large.)
return sign_ * ldexp(static_cast<double>(d_mantissa), bn_exp_);
return sign_ * std::ldexp(static_cast<double>(d_mantissa), bn_exp_);
}

ExactFloat ExactFloat::RoundToMaxPrec(int max_prec, RoundingMode mode) const {
Expand Down Expand Up @@ -336,7 +336,7 @@ int ExactFloat::NumSignificantDigitsForPrec(int prec) {
//
// Since either of these bounds can be too large by 0, 1, or 2 digits, we
// stick with the simpler first bound.
return static_cast<int>(1 + ceil(prec * (M_LN2 / M_LN10)));
return static_cast<int>(1 + std::ceil(prec * (M_LN2 / M_LN10)));
}

// Numbers are always formatted with at least this many significant digits.
Expand Down