Coverage Report

Created: 2023-09-25 06:08

/src/dropbear/libtommath/bn_mp_cmp_d.c
Line
Count
Source (jump to first uncovered line)
1
#include "tommath_private.h"
2
#ifdef BN_MP_CMP_D_C
3
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
4
/* SPDX-License-Identifier: Unlicense */
5
6
/* compare a digit */
7
mp_ord mp_cmp_d(const mp_int *a, mp_digit b)
8
1.59M
{
9
   /* compare based on sign */
10
1.59M
   if (a->sign == MP_NEG) {
11
792k
      return MP_LT;
12
792k
   }
13
14
   /* compare based on magnitude */
15
800k
   if (a->used > 1) {
16
800k
      return MP_GT;
17
800k
   }
18
19
   /* compare the only digit of a to b */
20
435
   if (a->dp[0] > b) {
21
92
      return MP_GT;
22
343
   } else if (a->dp[0] < b) {
23
0
      return MP_LT;
24
343
   } else {
25
343
      return MP_EQ;
26
343
   }
27
435
}
28
#endif