MCPcopy Create free account
hub / github.com/apache/singa / scalbln

Function scalbln

include/half.hpp:4148–4163  ·  view source on GitHub ↗

Multiply by power of two. This function is exact to rounding for all rounding modes. See also:** Documentation for [std::scalbln](https://en.cppreference.com/w/cpp/numeric/math/scalbn). \param arg number to modify \param exp power of two to multiply with \return \a arg multplied by 2 raised to \a exp \exception FE_INVALID for signaling NaN \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT accordin

Source from the content-addressed store, hash-verified

4146 /// \exception FE_INVALID for signaling NaN
4147 /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
4148 inline half scalbln(half arg, long exp)
4149 {
4150 unsigned int abs = arg.data_ & 0x7FFF, sign = arg.data_ & 0x8000;
4151 if(abs >= 0x7C00 || !abs)
4152 return (abs>0x7C00) ? half(detail::binary, detail::signal(arg.data_)) : arg;
4153 for(; abs<0x400; abs<<=1,--exp) ;
4154 exp += abs >> 10;
4155 if(exp > 30)
4156 return half(detail::binary, detail::overflow<half::round_style>(sign));
4157 else if(exp < -10)
4158 return half(detail::binary, detail::underflow<half::round_style>(sign));
4159 else if(exp > 0)
4160 return half(detail::binary, sign|(exp<<10)|(abs&0x3FF));
4161 unsigned int m = (abs&0x3FF) | 0x400;
4162 return half(detail::binary, detail::rounded<half::round_style,false>(sign|(m>>(1-exp)), (m>>-exp)&1, (m&((1<<-exp)-1))!=0));
4163 }
4164
4165 /// Multiply by power of two.
4166 /// This function is exact to rounding for all rounding modes.

Callers 2

scalbnFunction · 0.85
ldexpFunction · 0.85

Calls 2

halfClass · 0.85
signalFunction · 0.85

Tested by

no test coverage detected