temporary undoing of renaming
[riscv-isa-sim.git] / softfloat / f64_to_i64_r_minMag.c
1
2 #include <stdbool.h>
3 #include <stdint.h>
4 #include "platform.h"
5 #include "internals.h"
6 #include "softfloat.h"
7
8 int_fast64_t f64_to_i64_r_minMag( float64_t a, bool exact )
9 {
10 union ui64_f64 uA;
11 uint_fast64_t uiA;
12 bool sign;
13 int_fast16_t exp;
14 uint_fast64_t sig;
15 int_fast16_t shiftCount;
16 int_fast64_t absZ;
17
18 uA.f = a;
19 uiA = uA.ui;
20 sign = signF64UI( uiA );
21 exp = expF64UI( uiA );
22 sig = fracF64UI( uiA );
23 shiftCount = exp - 0x433;
24 if ( 0 <= shiftCount ) {
25 if ( 0x43E <= exp ) {
26 if ( uiA != packToF64UI( 1, 0x43E, 0 ) ) {
27 softfloat_raiseFlags( softfloat_flag_invalid );
28 if ( ! sign || ( ( exp == 0x7FF ) && sig ) ) {
29 return INT64_C( 0x7FFFFFFFFFFFFFFF );
30 }
31 }
32 return - INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
33 }
34 sig |= UINT64_C( 0x0010000000000000 );
35 absZ = sig<<shiftCount;
36 } else {
37 if ( exp < 0x3FF ) {
38 if ( exact && ( exp | sig ) ) {
39 softfloat_exceptionFlags |= softfloat_flag_inexact;
40 }
41 return 0;
42 }
43 sig |= UINT64_C( 0x0010000000000000 );
44 absZ = sig>>( - shiftCount );
45 if ( exact && (uint64_t) ( sig<<( shiftCount & 63 ) ) ) {
46 softfloat_exceptionFlags |= softfloat_flag_inexact;
47 }
48 }
49 return sign ? - absZ : absZ;
50
51 }
52