IsMagnitudeAtMost🔗
Check that the number given as
digits is at most limit.
Both digits and limit are expected to be decimal digits
without a sign and without leading zeros. An empty text represents zero.
We compare the numbers digit by digit, since they might not fit into an integer.
Code
if len(digits) != len(limit):
return len(digits) < len(limit)
for i in range(0, len(digits)):
digit = int(digits[i : i + 1])
limit_digit = int(limit[i : i + 1])
if digit != limit_digit:
return digit < limit_digit
return True