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

Go to the source code of this file.

Functions

int_fast64_t softfloat_roundToI64 (bool sign, uint_fast64_t sig, uint_fast64_t sigExtra, uint_fast8_t roundingMode, bool exact)
 

Function Documentation

◆ softfloat_roundToI64()

int_fast64_t softfloat_roundToI64 ( bool sign,
uint_fast64_t sig,
uint_fast64_t sigExtra,
uint_fast8_t roundingMode,
bool exact )

Definition at line 45 of file s_roundToI64.c.

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