| 33 | } |
| 34 | |
| 35 | int32_t floatToInt(float value){ |
| 36 | Twiddle<float> u(value); |
| 37 | u.u += 0x800000; |
| 38 | |
| 39 | if(u.u & 0x40000000){ // mag outside [0, 1) |
| 40 | int32_t shift = ((u.u)>>23) & 0x7F; |
| 41 | int32_t sign = u.u & MaskSign<float>(); |
| 42 | int32_t result = (1<<shift) | ((u.u & MaskFrac<float>())>>(23-shift)); |
| 43 | |
| 44 | if(sign){ // negative number |
| 45 | result = ~result + 1; // 2's complement |
| 46 | } |
| 47 | return result; |
| 48 | } |
| 49 | else{ |
| 50 | return 0; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | float split(float value, int32_t& intPart){ |
| 55 | Twiddle<float> u(value); |
nothing calls this directly
no outgoing calls
no test coverage detected