def Digits.to_byte

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

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

68# The byte of two digits, the high digit first: 16 times the high digit plus
69# the low one, from 0 to 255. Its bits 7 to 4 are the high digit's, bits 3 to
70# 0 the low digit's, and the other 24 bits are zero.
71def Digits.to_byte(digits: Digits(2n)) -> U32:
72  match digits:
73    case DCon{+high, DCon{+low, DNil{}}}:
74      U32{WCon{Hex.Digit.is_odd(low), WCon{Hex.Digit.has_bit1(low), WCon{Hex.Digit.has_bit2(low), WCon{Hex.Digit.has_bit3(low), WCon{Hex.Digit.is_odd(high), WCon{Hex.Digit.has_bit1(high), WCon{Hex.Digit.has_bit2(high), WCon{Hex.Digit.has_bit3(high), Word.zero(24n)}}}}}}}}}

Uses (10)

Used by (1)