Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
s_roundMToUI64.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_roundMToUI64.c:

Go to the source code of this file.

Functions

uint_fast64_t softfloat_roundMToUI64 (bool sign, uint32_t *extSigPtr, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ softfloat_roundMToUI64()

uint_fast64_t softfloat_roundMToUI64 ( bool sign,
uint32_t * extSigPtr,
uint_fast8_t roundingMode,
bool exact )

Definition at line 45 of file s_roundMToUI64.c.

47{
48 uint64_t sig;
49 uint32_t sigExtra;
50
51 /*------------------------------------------------------------------------
52 *------------------------------------------------------------------------*/
53 sig =
54 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
55 | extSigPtr[indexWord( 3, 1 )];
56 sigExtra = extSigPtr[indexWordLo( 3 )];
57 if (
58 (roundingMode == softfloat_round_near_maxMag)
59 || (roundingMode == softfloat_round_near_even)
60 ) {
61 if ( 0x80000000 <= sigExtra ) goto increment;
62 } else {
63 if ( sign ) {
64 if ( !(sig | sigExtra) ) return 0;
65 if ( roundingMode == softfloat_round_min ) goto invalid;
66#ifdef SOFTFLOAT_ROUND_ODD
67 if ( roundingMode == softfloat_round_odd ) goto invalid;
68#endif
69 } else {
70 if ( (roundingMode == softfloat_round_max) && sigExtra ) {
71 increment:
72 ++sig;
73 if ( !sig ) goto invalid;
74 if (
75 (sigExtra == 0x80000000)
76 && (roundingMode == softfloat_round_near_even)
77 ) {
78 sig &= ~(uint_fast64_t) 1;
79 }
80 }
81 }
82 }
83 if ( sign && sig ) goto invalid;
84 if ( sigExtra ) {
85#ifdef SOFTFLOAT_ROUND_ODD
86 if ( roundingMode == softfloat_round_odd ) sig |= 1;
87#endif
89 }
90 return sig;
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 invalid:
96
97}
void softfloat_raiseFlags(uint_fast8_t flags)
#define ui64_fromPosOverflow
Definition specialize.h:65
#define ui64_fromNegOverflow
Definition specialize.h:66
#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
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
Here is the call graph for this function:
Here is the caller graph for this function: