Use a common function to calculate the number of hex digits

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei 2023-02-14 18:25:23 +01:00
parent aef0f2de9f
commit 7c8d706f4e
No known key found for this signature in database
GPG key ID: F072ACA227ACD71D

View file

@ -74,6 +74,10 @@ def combination_pairs(values: List[T]) -> List[Tuple[T, T]]:
"""Return all pair combinations from input values."""
return [(x, y) for x in values for y in values]
def hex_digits_for_limb(limbs: int, bits_in_limb: int) -> int:
""" Retrun the hex digits need for a number of limbs. """
return 2 * (limbs * bits_in_limb // 8)
class OperationCommon(test_data_generation.BaseTest):
"""Common features for bignum binary operations.
@ -138,7 +142,7 @@ class OperationCommon(test_data_generation.BaseTest):
@property
def hex_digits(self) -> int:
return 2 * (self.limbs * self.bits_in_limb // 8)
return hex_digits_for_limb(self.limbs, self.bits_in_limb)
def format_arg(self, val: str) -> str:
if self.input_style not in self.input_styles: