blob: d42cbe8067ed21d953e9ef5a96e17cc7c2032fe9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "primitives.h"
#include "internals.h"
#include "softfloat.h"
float64_t i32_to_f64( int_fast32_t a )
{
uint_fast64_t uiZ;
bool sign;
uint_fast32_t absA;
int shiftCount;
union ui64_f64 uZ;
if ( ! a ) {
uiZ = 0;
} else {
sign = ( a < 0 );
absA = sign ? - a : a;
shiftCount = softfloat_countLeadingZeros32( absA ) + 21;
uiZ =
packToF64UI(
sign, 0x432 - shiftCount, (uint_fast64_t) absA<<shiftCount );
}
uZ.ui = uiZ;
return uZ.f;
}
|