Explorer

definy.text-hex-value

description
The value of a hex digit byte, or -1
type
Fn(byte: Number) -> Number
expression
fn(byte$0) =>
  match @definy.text-is-digit(byte: $0) {
    true =>
      @core.minus(left: $0, right: 48),
    false =>
      match @core.and(
          left: @core.less-than-or-equal(left: 97, right: $0),
          right: @core.less-than-or-equal(left: $0, right: 102)
        ) {
        true =>
          @core.minus(left: $0, right: 87),
        false =>
          match @core.and(
              left: @core.less-than-or-equal(left: 65, right: $0),
              right: @core.less-than-or-equal(left: $0, right: 70)
            ) {
            true =>
              @core.minus(left: $0, right: 55),
            false =>
              @core.minus(left: 0, right: 1)
          }
      }
  }
visibility
public
definy.text-hex-value (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: vZdDMPFpzRCPD3vZSTQuFzfwDCqHo0GMHAJC-WlbEgY
content hash: oS0z9pgudjPTDH2QFJ5Cbf-3U-Xt9NVftR4spqYbm6g