Skip to content

Commit 9b5da0f

Browse files
committed
BUGFIX! fix definition of DFRAC_almost1v.
Found thanks to frama-c. Backported from the formal-verification branch.
1 parent debfb88 commit 9b5da0f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

include/fixed_point/types.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,20 @@ static inline efrac _efrac(efrac_base v)
140140
return r;
141141
}
142142

143-
#define MFRAC_BIT (16) /*!< Size in bits of a FRAC. */
143+
#define MFRAC_FBIT (8) /*!< Size in bits of the fractional part of a MFRAC. */
144+
#define MFRAC_IBIT (8) /*!< Size in bits of the integer part of a MFRAC. */
145+
#define MFRAC_BIT (16) /*!< Size in bits of a MFRAC. */
146+
147+
#define FRAC_FBIT (15) /*!< Size in bits of the fractional part of a FRAC. */
148+
#define FRAC_IBIT (1) /*!< Size in bits of the integer part of a FRAC. */
144149
#define FRAC_BIT (16) /*!< Size in bits of a FRAC. */
150+
151+
#define DFRAC_FBIT (30) /*!< Size in bits of the fractional part of a DFRAC. */
152+
#define DFRAC_IBIT (2) /*!< Size in bits of the integer part of a DFRAC. */
145153
#define DFRAC_BIT (32) /*!< Size in bits of a DFRAC. */
154+
155+
#define EFRAC_FBIT (15) /*!< Size in bits of the fractional part of an EFRAC. */
156+
#define EFRAC_IBIT (17) /*!< Size in bits of the integer part of an EFRAC. */
146157
#define EFRAC_BIT (32) /*!< Size in bits of an EFRAC. */
147158

148159
/**
@@ -234,7 +245,7 @@ typedef dfrac frac_s32; /*!< 32 bit signed fractional */
234245
*
235246
* This represents the same value as FRAC_1 (1 - 2**(-15)), but expressed as
236247
* a dfrac */
237-
#define DFRAC_almost1_V (-(INT32_MIN>>1)-1)
248+
#define DFRAC_almost1_V (FRAC_1_V<<(DFRAC_FBIT-FRAC_FBIT))
238249

239250
/** dfrac for -1. */
240251
#define DFRAC_minus1_V (INT32_MIN>>1)

0 commit comments

Comments
 (0)