hex.input_dec_uint_untilΒΆ
dst[:n] = the unsigned decimal number read from input (mod 16^n).
Reads ASCII '0'..'9' and STOPS at the first non-digit byte, which is stored in stop_byte[:2]. The primitive behind hex.input_dec_uint.
SignatureΒΆ
def input_dec_uint_until n, dst, stop_byte @ loop, digit_lo, add_digit, digit, done { ... }
Defined in hex/input.fj β lines 101β118 (view on GitHub).
ComplexityΒΆ
Time:
~ nd(10@+39) (d = number of digits)Space:
~ n(9@+132)
See the complexity glossary for what @, w, dw, dbit, n mean.
Requires initΒΆ
The following must be initialised before this macro is invoked:
hex.init
SourceΒΆ
Click to view the macro body
def input_dec_uint_until n, dst, stop_byte @ loop, digit_lo, add_digit, digit, done {
.zero n, dst
.zero n, digit
loop:
.input stop_byte
.if_flags stop_byte+dw, 1<<3, done, digit_lo // high nibble != 3 -> not '0'-'9' -> stop
digit_lo:
.if_flags stop_byte, (1<<10)-1, done, add_digit // low nibble not 0..9 -> not a digit -> stop
add_digit:
.mul10 n, dst
.zero digit
.xor digit, stop_byte
.add n, dst, digit
;loop
digit: hex.vec n
done:
}
Depends onΒΆ
Used byΒΆ
Example usesΒΆ
hex.input_dec_uintinhex/input.fj
β Previous: hex.input_as_hex/3
Next: hex.input_dec_int_until β