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

Go to the source code of this file.

Functions

uint_fast64_t softfloat_roundToUI64 (bool sign, uint_fast64_t sig, uint_fast64_t sigExtra, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ softfloat_roundToUI64()

uint_fast64_t softfloat_roundToUI64 ( bool sign,
uint_fast64_t sig,
uint_fast64_t sigExtra,
uint_fast8_t roundingMode,
bool exact )

Definition at line 45 of file s_roundToUI64.c.

52{
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 if (
57 (roundingMode == softfloat_round_near_maxMag)
58 || (roundingMode == softfloat_round_near_even)
59 ) {
60 if ( UINT64_C( 0x8000000000000000 ) <= sigExtra ) goto increment;
61 } else {
62 if ( sign ) {
63 if ( !(sig | sigExtra) ) return 0;
64 if ( roundingMode == softfloat_round_min ) goto invalid;
65#ifdef SOFTFLOAT_ROUND_ODD
66 if ( roundingMode == softfloat_round_odd ) goto invalid;
67#endif
68 } else {
69 if ( (roundingMode == softfloat_round_max) && sigExtra ) {
70 increment:
71 ++sig;
72 if ( !sig ) goto invalid;
73 if (
74 (sigExtra == UINT64_C( 0x8000000000000000 ))
75 && (roundingMode == softfloat_round_near_even)
76 ) {
77 sig &= ~(uint_fast64_t) 1;
78 }
79 }
80 }
81 }
82 if ( sign && sig ) goto invalid;
83 if ( sigExtra ) {
84#ifdef SOFTFLOAT_ROUND_ODD
85 if ( roundingMode == softfloat_round_odd ) sig |= 1;
86#endif
88 }
89 return sig;
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 invalid:
95
96}
void softfloat_raiseFlags(uint_fast8_t flags)
#define ui64_fromPosOverflow
Definition specialize.h:65
#define ui64_fromNegOverflow
Definition specialize.h:66
@ 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
uint64_t uint_fast64_t
Definition stdint.h:157
#define UINT64_C(val)
Definition stdint.h:284
Here is the call graph for this function:
Here is the caller graph for this function: