Coverage Report

Created: 2025-07-18 06:54

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