Skip to content

Commit 111afcc

Browse files
authored
Merge pull request #560 from czurnieden/mp_isone
Added macro mp_isone
2 parents c6a00c2 + 5c4f5d9 commit 111afcc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

doc/bn.tex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,12 @@ \section{Function Macros}
26582658
\end{alltt}
26592659
Checks if $a = 0$. It does not check if the amount of memory allocated for $a$ is also minimal.
26602660

2661+
\index{mp\_isone}
2662+
\begin{alltt}
2663+
bool mp_isone(mp_int *a)
2664+
\end{alltt}
2665+
Checks if $a = 1$.
2666+
26612667
Other macros which are either shortcuts to normal functions or just other names for them do have
26622668
their place in a programmer's life, too!
26632669

tommath.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ mp_err mp_init_size(mp_int *a, int size) MP_WUR;
208208

209209
/* ---> Basic Manipulations <--- */
210210
#define mp_iszero(a) ((a)->used == 0)
211+
#define mp_isone(a) ( ((a)->sign == MP_ZPOS) && ((a)->used == 1u) && ((a)->dp[0] == 1u) )
211212
#define mp_isneg(a) ((a)->sign == MP_NEG)
212213
#define mp_iseven(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
213214
#define mp_isodd(a) (!mp_iseven(a))

0 commit comments

Comments
 (0)