[an error occurred while processing this directive]
|
Юзал нечто такое - к сожалению весь сорс дать не могу - продано :-)
//saturation - shall be applied after the normilization
inline void CFastFloat::saturate() const{
if(_abs(m_exp) < m_max_abs_exponent)
return;
//handle large numbers
if(m_exp > m_max_abs_exponent){
m_exp = m_max_abs_exponent;
if(m_mant < 0)
m_mant = -m_max_pos_mant;
else
m_mant = m_max_pos_mant;
}
//handle numbers smaller then machine precision - replace them with machine zero.
if((-m_exp) > m_max_abs_exponent){
m_exp = -m_max_abs_exponent;
m_mant = 0;
}
}
//normalization
inline void CFastFloat::normalize() const{
int same_bits;
//same bits excluding sign
same_bits = _norm((UWord32) m_mant << 16);
m_mant = (m_mant << same_bits);
m_exp -= same_bits;
if(m_mant == 0){
m_exp = -m_max_abs_exponent;
}
#ifndef FLT_SATURATION_OFF
saturate();
#endif
}
inline CFastFloat& CFastFloat::operator*=(const CFastFloat& x){
//sum exponents
m_exp += (x.m_exp + 15);
//mpy mantissa
m_mant = (short)_mpylir(m_mant,x.m_mant);
//normalize result
normalize();
return *this;
}
E-mail: info@telesys.ru