Skip to content

Commit

Permalink
Merge pull request #560 from czurnieden/mp_isone
Browse files Browse the repository at this point in the history
Added macro mp_isone
  • Loading branch information
sjaeckel authored Jun 21, 2023
2 parents c6a00c2 + 5c4f5d9 commit 111afcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/bn.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2658,6 +2658,12 @@ \section{Function Macros}
\end{alltt}
Checks if $a = 0$. It does not check if the amount of memory allocated for $a$ is also minimal.

\index{mp\_isone}
\begin{alltt}
bool mp_isone(mp_int *a)
\end{alltt}
Checks if $a = 1$.

Other macros which are either shortcuts to normal functions or just other names for them do have
their place in a programmer's life, too!

Expand Down
1 change: 1 addition & 0 deletions tommath.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ mp_err mp_init_size(mp_int *a, int size) MP_WUR;

/* ---> Basic Manipulations <--- */
#define mp_iszero(a) ((a)->used == 0)
#define mp_isone(a) ( ((a)->sign == MP_ZPOS) && ((a)->used == 1u) && ((a)->dp[0] == 1u) )
#define mp_isneg(a) ((a)->sign == MP_NEG)
#define mp_iseven(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
#define mp_isodd(a) (!mp_iseven(a))
Expand Down

0 comments on commit 111afcc

Please sign in to comment.