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 as strings, since they might not fit into an integer. The digits of numbers of equal length are ordered as the numbers themselves.
Code
if len(digits) != len(limit):
return len(digits) < len(limit)
return digits <= limit