def num.go

bend-kit-redis@0.3.0.0 · redis.bend:251

import bend-kit-redis@0.3.0.0/redis.bend as Redis
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

251# n digits from i: (hi, lo) = (hi, lo) * 10 + d over 16-bit limbs. 19 digits stay below 2^64.
252def num.go(n: Nat, r: Array<U32> & U32, +i: U32, +hi: U32, +lo: U32, +ok: Bool) -> Array<U32> & U32 & U32 & Bool:
253  match n:
254    case 0n:
255      (a, c) = r
256      (a, hi, lo, ok)
257    case 1n+p:
258      (a, +c) = r
259      +d = (c - 48 : U32)
260      +p0 = ((lo .&. 65535) * 10 + d : U32)
261      +p1 = ((lo >> 16n) * 10 + (p0 >> 16n) : U32)
262      num.go(p, Bytes.peek(a, (i + 1 : U32)), (i + 1 : U32), (hi * 10 + (p1 >> 16n) : U32), ((p1 << 16n) .|. (p0 .&. 65535) : U32), Bool.and(ok, U32.is_lt(d, 10)))

Uses (16)

Used by (1)