Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. template<class F, class>
  2. void
  3. number::
  4. assign(F v) noexcept
  5. {
  6. static exponent_type const bias =
  7. static_cast<exponent_type>(std::floor(
  8. std::log10((std::numeric_limits<
  9. mantissa_type>::max)()))) - 1;
  10. if(v < 0)
  11. {
  12. v = -v;
  13. neg_ = true;
  14. }
  15. else
  16. {
  17. neg_ = false;
  18. }
  19. exp_ = static_cast<exponent_type>(
  20. std::floor(std::log10(v))) - bias;
  21. mant_ = static_cast<mantissa_type>(
  22. v / std::pow(10, exp_));
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement