Hexadecimal GitHub issue

vibecode
{"vibecode": {
    "doc": "hex",
    "role": "brainstorm: should Puck have a Hexadecimal class — a Number subclass whose default string form is hex?",
    "status": "closed — may be revisited when a concrete consumer asks for it",
    "closed_on": "2026-05-22",
    "reason_closed": "color library owns its hex parsing/formatting; no other consumer is asking today; format methods on Number cover the same ground without a new type"
}}

Status: closed — may be revisited. Color owns its hex parsing and formatting, and no other consumer is asking for a Hex type today. Format methods on Number (e.g. $n.to_hex(digits:, prefix:) and Number.from_hex($string)) cover the same ground without introducing a new class. Reach back here if a real consumer (binary protocols, file hashes, anything that genuinely wants hex as its own type) shows up wanting it.

The brainstorm that follows is preserved for that future revisit.


The idea GitHub issue

caspian
$n = %puck['https://puck.uno/hex'].new(255)
$n.to_string    # 'ff'
$n + 1          # 256 (arithmetic stays numeric)

$rgb = Hex.parse('#ff0000')   # 16711680

A Hex IS a number — arithmetic, comparison, ordering, range membership all just work. It only differs from a plain Number in two ways: it parses from hex strings and its default string form is hex.


Why it might be worth it GitHub issue


Why it might not be worth it GitHub issue


Open questions GitHub issue


© 2026 Puck.uno