aboutsummaryrefslogtreecommitdiff
path: root/softfloat/ui32_to_f64.c
blob: b93ddf72313edeae5d826870d2ed7687a160bade (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
// See LICENSE.SoftFloat for license details.


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

float64_t ui32_to_f64( uint_fast32_t a )
{
    uint_fast64_t uiZ;
    int shiftCount;
    union ui64_f64 uZ;

    if ( ! a ) {
        uiZ = 0;
    } else {
        shiftCount = softfloat_countLeadingZeros32( a ) + 21;
        uiZ =
            packToF64UI(
                0, 0x432 - shiftCount, (uint_fast64_t) a<<shiftCount );
    }
    uZ.ui = uiZ;
    return uZ.f;

}