@@ -56,13 +56,13 @@ extern "C" {
56
56
57
57
#ifdef FLEXFLOAT_ON_SINGLE
58
58
#define UINT_C UINT32_C
59
- #define MASK_FRAC (UINT32_C(0x007FFFFF))
60
- #define MASK_FRAC_MSB (UINT32_C(0x00800000))
61
- #define MASK_FRAC_EXCEPT_MSB (UINT32_C(0x003FFFFF))
59
+ #define MASK_FRAC (UINT32_C(0x007FFFFF)) //biggest denormal (subnormal) value (23 ones)
60
+ #define MASK_FRAC_MSB (UINT32_C(0x00800000)) //smallest normal value? (MSB of 24 bit value) (1 followed by 23 zeros)
61
+ #define MASK_FRAC_EXCEPT_MSB (UINT32_C(0x003FFFFF)) //sign bit? (22 ones)
62
62
#define SMALLEST_NORM_POS (0x00800000)
63
63
#define SMALLEST_NORM_NEG (0x80800000)
64
- #define INF_EXP (0xFF)
65
- #define BIAS (127)
64
+ #define INF_EXP (0xFF) //integer value of 255 (8 ones)
65
+ #define BIAS (127) //bias for exponent
66
66
#define NUM_BITS (32)
67
67
#define NUM_BITS_EXP (8)
68
68
#define NUM_BITS_FRAC (23)
@@ -136,7 +136,14 @@ typedef __float128 fp_t;
136
136
// Helper macros
137
137
138
138
#define SIGN ( a ) ((bool) ((uint_t) (a)>>(NUM_BITS-1)))
139
- #define EXPONENT ( a ) ((int_fast16_t) ((uint_t) (a)>>NUM_BITS_FRAC) & INF_EXP)
139
+
140
+ // (a) >> NUM_BITS_FRAC shifts bits to the right by number of fractional bits to obtain the bits in the sign and exponent.
141
+ // ( ) & INF_EXP zeros out everything except for the bits corresponding to the exponent.
142
+ // Thus the final result is the exponent value.
143
+ #define EXPONENT ( a ) ((int_fast16_t) ((uint_t) (a)>>NUM_BITS_FRAC) & INF_EXP)
144
+
145
+ // shifts bits of sign and exp values so that they are in their appropriate bit precisions.
146
+ // then adds everything to get binary representation of number with corresponding sign, exp, and significant
140
147
#define PACK ( sign , exp , sig ) ((uint_t) (((uint_t) (sign)<<(NUM_BITS-1)) + ((uint_t) (exp)<<NUM_BITS_FRAC) + (sig)))
141
148
142
149
#define CAST_TO_INT (d ) (*((int_t *)(&(d))))
@@ -154,6 +161,7 @@ struct _flexfloat_t;
154
161
typedef struct _flexfloat_t flexfloat_t ;
155
162
typedef void (* ff_function_p )(flexfloat_t * , void * );
156
163
164
+ // probably need to come back to this to understand other things
157
165
typedef struct _flexfloat_desc_t {
158
166
uint8_t exp_bits ;
159
167
uint8_t frac_bits ;
0 commit comments