Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fixunsdfti.c File Reference
#include "fp64.h"
Include dependency graph for fixunsdfti.c:

Go to the source code of this file.

Functions

fixuint_t ___fixunsdfti (uint64_t a)
 

Function Documentation

◆ ___fixunsdfti()

fixuint_t ___fixunsdfti ( uint64_t a)

Definition at line 15 of file fixunsdfti.c.

15 {
16 // Break a into sign, exponent, significand
17 const rep_t aRep = a;
18 const rep_t aAbs = aRep & absMask;
19 const int sign = aRep & signBit ? -1 : 1;
20 const int exponent = (aAbs >> significandBits) - exponentBias;
21 const rep_t significand = (aAbs & significandMask) | implicitBit;
22
23 // If either the value or the exponent is negative, the result is zero.
24 if (sign == -1 || exponent < 0)
25 return 0;
26
27 // If the value is too large for the integer type, saturate.
28 if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT)
29 return ~(fixuint_t)0;
30
31 // If 0 <= exponent < significandBits, right shift to get the result.
32 // Otherwise, shift left.
33 if (exponent < significandBits)
34 return significand >> (significandBits - exponent);
35 else
36 return (fixuint_t)significand << (exponent - significandBits);
37}
unsigned __int128 fixuint_t
Definition fixdfti.c:14
__int128 rep_t
Definition fixunstfti.c:16
#define implicitBit
Definition fp128.h:15
#define signBit
Definition fp128.h:17
#define exponentBias
Definition fp128.h:13
#define significandBits
Definition fp128.h:9
#define significandMask
Definition fp128.h:16
#define absMask
Definition fp128.h:18
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
Here is the caller graph for this function: