Coverage Report

Created: 2023-09-25 06:11

/src/dropbear/libtommath/bn_mp_cmp_d.c
Line
Count
Source
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
12.1M
{
9
   /* compare based on sign */
10
12.1M
   if (a->sign == MP_NEG) {
11
5.66M
      return MP_LT;
12
5.66M
   }
13
14
   /* compare based on magnitude */
15
6.50M
   if (a->used > 1) {
16
6.47M
      return MP_GT;
17
6.47M
   }
18
19
   /* compare the only digit of a to b */
20
29.5k
   if (a->dp[0] > b) {
21
9.76k
      return MP_GT;
22
19.8k
   } else if (a->dp[0] < b) {
23
29
      return MP_LT;
24
19.8k
   } else {
25
19.8k
      return MP_EQ;
26
19.8k
   }
27
29.5k
}
28
#endif