aboutsummaryrefslogtreecommitdiff
path: root/softfloat/i32_to_f32.c
blob: f51facdfd707176f242bd5664f12d716ab1df6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "internals.h"
#include "softfloat.h"

float32_t i32_to_f32( int_fast32_t a )
{
    bool sign;
    union ui32_f32 uZ;

    sign = ( a < 0 );
    if ( ! ( a & 0x7FFFFFFF ) ) {
        uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
        return uZ.f;
    }
    return softfloat_normRoundPackToF32( sign, 0x9C, sign ? - a : a );

}