daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template<class F>
  2. void
  3. number::
  4. assign(F v
  5.     ,typename std::enable_if<
  6.         std::is_floating_point<
  7.         F>::value>::type*) noexcept
  8. {
  9.     static exponent_type const bias =
  10.         static_cast<exponent_type>(std::floor(
  11.             std::log10((std::numeric_limits<
  12.                 mantissa_type>::max)()))) - 2;
  13.     if(v < 0)
  14.     {
  15.         v = std::abs(v);
  16.         neg_ = true;
  17.     }
  18.     else
  19.     {
  20.         neg_ = false;
  21.     }
  22.     exp_ = static_cast<exponent_type>(
  23.         std::floor(std::log10(v))) - bias;
  24.     mant_ = static_cast<mantissa_type>(
  25.         v / std::pow(10, exp_));
  26.     normalize();
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top