Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
s_roundMToI64.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "internals.h"
#include "specialize.h"
#include "softfloat.h"
Include dependency graph for s_roundMToI64.c:

Go to the source code of this file.

Functions

int_fast64_t softfloat_roundMToI64 (bool sign, uint32_t *extSigPtr, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ softfloat_roundMToI64()

int_fast64_t softfloat_roundMToI64 ( bool sign,
uint32_t * extSigPtr,
uint_fast8_t roundingMode,
bool exact )

Definition at line 45 of file s_roundMToI64.c.

47{
48 uint64_t sig;
49 uint32_t sigExtra;
50 union { uint64_t ui; int64_t i; } uZ;
51 int64_t z;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 sig =
56 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
57 | extSigPtr[indexWord( 3, 1 )];
58 sigExtra = extSigPtr[indexWordLo( 3 )];
59 if (
60 (roundingMode == softfloat_round_near_maxMag)
61 || (roundingMode == softfloat_round_near_even)
62 ) {
63 if ( 0x80000000 <= sigExtra ) goto increment;
64 } else {
65 if (
66 sigExtra
67 && (sign
68 ? (roundingMode == softfloat_round_min)
69#ifdef SOFTFLOAT_ROUND_ODD
70 || (roundingMode == softfloat_round_odd)
71#endif
72 : (roundingMode == softfloat_round_max))
73 ) {
74 increment:
75 ++sig;
76 if ( !sig ) goto invalid;
77 if (
78 (sigExtra == 0x80000000)
79 && (roundingMode == softfloat_round_near_even)
80 ) {
81 sig &= ~(uint_fast64_t) 1;
82 }
83 }
84 }
85 uZ.ui = sign ? -sig : sig;
86 z = uZ.i;
87 if ( z && ((z < 0) ^ sign) ) goto invalid;
88 if ( sigExtra ) {
89#ifdef SOFTFLOAT_ROUND_ODD
90 if ( roundingMode == softfloat_round_odd ) z |= 1;
91#endif
93 }
94 return z;
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 invalid:
100
101}
void softfloat_raiseFlags(uint_fast8_t flags)
#define i64_fromNegOverflow
Definition specialize.h:69
#define i64_fromPosOverflow
Definition specialize.h:68
#define indexWordLo(total)
#define indexWord(total, n)
@ softfloat_flag_invalid
Definition softfloat.h:89
@ softfloat_flag_inexact
Definition softfloat.h:85
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags
@ softfloat_round_odd
Definition softfloat.h:77
@ softfloat_round_max
Definition softfloat.h:75
@ softfloat_round_min
Definition softfloat.h:74
@ softfloat_round_near_even
Definition softfloat.h:72
@ softfloat_round_near_maxMag
Definition softfloat.h:76
signed __int64 int64_t
Definition stdint.h:135
unsigned int uint32_t
Definition stdint.h:126
uint64_t uint_fast64_t
Definition stdint.h:157
unsigned __int64 uint64_t
Definition stdint.h:136