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

Go to the source code of this file.

Typedefs

typedef __int128 fixint_t
 
typedef unsigned __int128 fixuint_t
 

Functions

fixint_t ___fixdfti (uint64_t a)
 

Typedef Documentation

◆ fixint_t

typedef __int128 fixint_t

Definition at line 13 of file fixdfti.c.

◆ fixuint_t

typedef unsigned __int128 fixuint_t

Definition at line 14 of file fixdfti.c.

Function Documentation

◆ ___fixdfti()

fixint_t ___fixdfti ( uint64_t a)

Definition at line 16 of file fixdfti.c.

16 {
17 const fixint_t fixint_max = (fixint_t)((~(fixuint_t)0) / 2);
18 const fixint_t fixint_min = -fixint_max - 1;
19 // Break a into sign, exponent, significand
20 const rep_t aRep = a;
21 const rep_t aAbs = aRep & absMask;
22 const fixint_t sign = aRep & signBit ? -1 : 1;
23 const int exponent = (aAbs >> significandBits) - exponentBias;
24 const rep_t significand = (aAbs & significandMask) | implicitBit;
25
26 // If exponent is negative, the result is zero.
27 if (exponent < 0)
28 return 0;
29
30 // If the value is too large for the integer type, saturate.
31 if ((unsigned)exponent >= sizeof(fixint_t) * CHAR_BIT)
32 return sign == 1 ? fixint_max : fixint_min;
33
34 // If 0 <= exponent < significandBits, right shift to get the result.
35 // Otherwise, shift left.
36 if (exponent < significandBits)
37 return sign * (significand >> (significandBits - exponent));
38 else
39 return sign * ((fixint_t)significand << (exponent - significandBits));
40
41}
__int128 fixint_t
Definition fixdfti.c:13
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: