-
Notifications
You must be signed in to change notification settings - Fork 5
/
fparithmetic.h
143 lines (121 loc) · 3.68 KB
/
fparithmetic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* fparithmetic.h
*
* Function prototypes and constants for fparithmetic.c
*
*/
#include <stdint.h>
#include "fpiface.h"
typedef union {
REAL64 fp;
uint64_t bits;
} fpreal64_t;
typedef union {
REAL32 fp;
uint32_t bits;
} fpreal32_t;
#define PINFINITY64 ((uint64_t)0x7ff0000000000000LL)
#define MINFINITY64 ((uint64_t)0xfff0000000000000LL)
#define NAN64_UNDEFINED ((uint64_t)0x7ff0000200000000LL)
#define NAN64_UNSTABLE ((uint64_t)0x7ff0000100000000LL)
#define NAN64_INEXACT ((uint64_t)0x7ff0000080000000LL)
#define ZERO64 ((uint64_t)0x0000000000000000LL)
/*
* REAL32 constants.
*/
extern fpreal32_t Zero;
extern fpreal32_t RUndefined;
/*
* REAL64 constants.
*/
extern fpreal64_t DZero;
extern fpreal64_t DUndefined;
/*
* Floating point initialization and exception handling.
*/
void fp_init (void);
void fp_chkexcept (char *msg);
void fp_syncexcept (void);
void fp_clrexcept (void);
/*
* Undocumented FPU status.
*/
fpreal64_t fp_state (int length, fpreal64_t r64, uint32_t *fps);
void fp_setstate (fpreal64_t r64, uint32_t fps);
/*
* Rounding mode.
*/
#define ROUND_Z 1
#define ROUND_N 2
#define ROUND_P 3
#define ROUND_M 4
void fp_setrounding (const char *where, int mode);
extern const char *RMODE;
/*
* REAL64 operations.
*/
int fp_signdb (fpreal64_t);
int fp_expdb (fpreal64_t);
uint64_t fp_fracdb (fpreal64_t);
int fp_nandb (fpreal64_t);
int fp_infdb (fpreal64_t);
int db_nan (uint64_t);
int db_inf (uint64_t);
fpreal64_t fp_adddb (fpreal64_t, fpreal64_t);
fpreal64_t fp_subdb (fpreal64_t, fpreal64_t);
fpreal64_t fp_muldb (fpreal64_t, fpreal64_t);
fpreal64_t fp_divdb (fpreal64_t, fpreal64_t);
fpreal64_t fp_mulby2db (fpreal64_t);
fpreal64_t fp_divby2db (fpreal64_t);
fpreal64_t fp_expinc32db (fpreal64_t);
fpreal64_t fp_expdec32db (fpreal64_t);
fpreal64_t fp_absdb (fpreal64_t);
fpreal64_t fp_sqrtfirstdb (fpreal64_t);
fpreal64_t fp_sqrtlastdb (fpreal64_t);
fpreal64_t fp_remfirstdb (fpreal64_t, fpreal64_t);
int fp_notfinitedb (fpreal64_t);
int fp_gtdb (fpreal64_t, fpreal64_t);
int fp_eqdb (fpreal64_t, fpreal64_t);
int fp_ordereddb (fpreal64_t, fpreal64_t);
fpreal64_t fp_r32tor64 (fpreal32_t);
fpreal64_t fp_intdb (fpreal64_t);
void fp_chki32db (fpreal64_t);
void fp_chki64db (fpreal64_t);
fpreal64_t fp_rtoi32db (fpreal64_t);
fpreal32_t fp_norounddb (fpreal64_t);
uint32_t fp_stnli32db (fpreal64_t);
fpreal64_t fp_i32tor64 (uint32_t);
fpreal64_t fp_b32tor64 (uint32_t);
/*
* REAL32 operations.
*/
int fp_signsn (fpreal32_t);
int fp_expsn (fpreal32_t);
uint32_t fp_fracsn (fpreal32_t);
int fp_nansn (fpreal32_t);
int fp_infsn (fpreal32_t);
int sn_nan (uint32_t);
int sn_inf (uint32_t);
fpreal32_t fp_addsn (fpreal32_t, fpreal32_t);
fpreal32_t fp_subsn (fpreal32_t, fpreal32_t);
fpreal32_t fp_mulsn (fpreal32_t, fpreal32_t);
fpreal32_t fp_divsn (fpreal32_t, fpreal32_t);
fpreal32_t fp_mulby2sn (fpreal32_t);
fpreal32_t fp_divby2sn (fpreal32_t);
fpreal32_t fp_expinc32sn (fpreal32_t);
fpreal32_t fp_expdec32sn (fpreal32_t);
fpreal32_t fp_abssn (fpreal32_t);
fpreal32_t fp_sqrtfirstsn (fpreal32_t);
fpreal32_t fp_sqrtlastsn (fpreal32_t);
fpreal32_t fp_remfirstsn (fpreal32_t, fpreal32_t);
int fp_notfinitesn (fpreal32_t);
int fp_gtsn (fpreal32_t, fpreal32_t);
int fp_eqsn (fpreal32_t, fpreal32_t);
int fp_orderedsn (fpreal32_t, fpreal32_t);
fpreal32_t fp_r64tor32 (fpreal64_t);
fpreal32_t fp_intsn (fpreal32_t);
void fp_chki32sn (fpreal32_t);
void fp_chki64sn (fpreal32_t);
fpreal32_t fp_rtoi32sn (fpreal32_t);
uint32_t fp_stnli32sn (fpreal32_t);
fpreal32_t fp_i32tor32 (uint32_t);