def Digits.of_byte

bend-trace-context@0.2.0.0 · src/digits.bend:76

import bend-trace-context@0.2.0.0/src/digits.bend as Digits
import Base
import bend-trace-context@0.2.0.0/src/hex.bend as Hex

76# The two digits of a byte, the high digit first: bits 7 to 4, then bits 3 to
77# 0. The other bits are not read, so the caller first checks that the word is
78# at most 255.
79def Digits.of_byte(byte: U32) -> Digits(2n):
80  match byte:
81    case U32{WCon{b0, WCon{b1, WCon{b2, WCon{b3, WCon{b4, WCon{b5, WCon{b6, WCon{b7, rest}}}}}}}}}:
82      DCon{Hex.Digit.from_bits(b4, b5, b6, b7), DCon{Hex.Digit.from_bits(b0, b1, b2, b3), DNil{}}}

Uses (6)

Used by (1)