IsMagnitudeAtMost🔗

Type: Transpilable verification function
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.

digits🔗
Number to be checked
limit🔗
Largest allowed number
Return🔗
True if digits is at most limit

Code

if len(digits) != len(limit):
    return len(digits) < len(limit)

return digits <= limit