Coverage Report

Created: 2025-08-26 06:41

/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
815k
{
9
   /* compare based on sign */
10
815k
   if (a->sign == MP_NEG) {
11
327k
      return MP_LT;
12
327k
   }
13
14
   /* compare based on magnitude */
15
488k
   if (a->used > 1) {
16
469k
      return MP_GT;
17
469k
   }
18
19
   /* compare the only digit of a to b */
20
18.2k
   if (a->dp[0] > b) {
21
7.67k
      return MP_GT;
22
10.6k
   } else if (a->dp[0] < b) {
23
1
      return MP_LT;
24
10.6k
   } else {
25
10.6k
      return MP_EQ;
26
10.6k
   }
27
18.2k
}
28
#endif