aboutsummaryrefslogtreecommitdiff
path: root/softfloat/i32_to_f32.c
blob: 1adad16334c98a07da7c0c834b8ee7848e80e682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// See LICENSE.SoftFloat for license details.


#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 );

}