Skip to content

Commit

Permalink
Allow to define custom MP_MIN_DIGIT_COUNT.
Browse files Browse the repository at this point in the history
  • Loading branch information
J08nY authored and sjaeckel committed Mar 12, 2024
1 parent f96ffdf commit 6dbb6fe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tommath_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,13 @@ MP_STATIC_ASSERT(correct_word_size, sizeof(mp_word) == (2u * sizeof(mp_digit)))
* - Must be large enough such that the mp_set_u64 setter can
* store uint64_t in the mp_int without growing
*/
#define MP_MIN_DIGIT_COUNT MP_MAX(3, (((int)MP_SIZEOF_BITS(uint64_t) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
#ifndef MP_MIN_DIGIT_COUNT
# define MP_MIN_DIGIT_COUNT MP_MAX(3, (((int)MP_SIZEOF_BITS(uint64_t) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
#endif
MP_STATIC_ASSERT(prec_geq_min_prec, MP_DEFAULT_DIGIT_COUNT >= MP_MIN_DIGIT_COUNT)
MP_STATIC_ASSERT(min_prec_geq_3, MP_MIN_DIGIT_COUNT >= 3)
MP_STATIC_ASSERT(min_prec_geq_uint64size,
MP_MIN_DIGIT_COUNT >= ((((int)MP_SIZEOF_BITS(uint64_t) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT))

/* Maximum number of digits.
* - Must be small enough such that mp_bit_count does not overflow.
Expand Down

0 comments on commit 6dbb6fe

Please sign in to comment.