Go to the source code of this file.
unsigned int float_to_uint32 |
( |
float |
value, |
|
|
char |
exponent, |
|
|
char |
significand, |
|
|
char |
denorm |
|
) |
| |
Definition at line 54 of file mangle.cpp.
References BITMASK, EXP_BITS, EXP_MASK, type_conv::fl_val, SIGN_MASK, SIGNIF_BITS, SIGNIF_MASK, and type_conv::u32_val.
57 unsigned int newval, tmpsig;
71 if (tmpexp > denorm && tmpsig&1) {
73 if ( tmpsig&( 1<<(significand+1) ) ) {
75 tmpsig -= 1<<(significand+1);
80 if (tmpexp == denorm) {
83 if ( tmpsig&(1<<significand) ) {
85 tmpsig -= 1<<significand;
88 tmpsig |= 1<<significand;
92 }
else if (tmpexp < denorm) {
93 tmpsig |= 1<<significand;
94 tmpsig >>= denorm-tmpexp;
100 }
else if (tmpexp >= (1<<exponent)+denorm) {
102 tmpsig =
BITMASK( significand );
106 newval |= (tmpexp<<significand)|tmpsig;
float uint32_to_float |
( |
unsigned int |
value, |
|
|
char |
exponent, |
|
|
char |
significand, |
|
|
char |
denorm |
|
) |
| |
Definition at line 110 of file mangle.cpp.
References BITMASK, type_conv::fl_val, SIGNIF_BITS, and type_conv::u32_val.
116 newval.
u32_val = ( 1<<(exponent+significand) )&value;
117 newval.u32_val <<= 31-(exponent+significand);
118 tmpsig = value&
BITMASK( significand );
119 tmpexp = value&(
BITMASK( exponent )<<significand);
120 tmpexp >>= significand;
122 if (tmpexp == 0 && tmpsig == 0) {
123 return newval.fl_val;
125 }
else if (tmpexp == 0) {
127 while ( !( tmpsig&(1<<significand) ) ) {
131 tmpsig -= 1<<significand;
133 tmpexp += 127+denorm;
137 newval.u32_val |= tmpsig;
139 return newval.fl_val;