Avoid type punning by using an integer/float union

This commit is contained in:
Danny Robson 2011-06-30 21:43:23 +10:00
parent c57a72705c
commit f29cb50ff7

View File

@ -62,7 +62,14 @@ ieee_float<E, S>::operator==(floating_t _floating) const {
// C++'s template bullshit for tonight.
check_hard (bits_type<TOTAL_BITS>::has_floating);
return m_bits == *(const uint_t*)&_floating;
union {
floating_t _floating;
uint_t _uint;
} convertor;
convertor._floating = _floating;
return m_bits == convertor._uint;
}