Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class F>
- void
- number::
- assign(F v
- ,typename std::enable_if<
- std::is_floating_point<
- F>::value>::type*) noexcept
- {
- static exponent_type const bias =
- static_cast<exponent_type>(std::floor(
- std::log10((std::numeric_limits<
- mantissa_type>::max)()))) - 2;
- if(v < 0)
- {
- v = std::abs(v);
- neg_ = true;
- }
- else
- {
- neg_ = false;
- }
- exp_ = static_cast<exponent_type>(
- std::floor(std::log10(v))) - bias;
- mant_ = static_cast<mantissa_type>(
- v / std::pow(10, exp_));
- normalize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement