On Thursday, 26 September 2024 at 06:53:12 UTC, Per Nordlöw wrote:
Should a function like

```d
uint parseHex(in char ch) pure nothrow @safe @nogc {
        switch (ch) {
        case '0': .. case '9':
                return ch - '0';
        case 'a': .. case 'f':
                return 10 + ch - 'a';
        case 'A': .. case 'F':
                return 10 + ch - 'A';
        default:
                assert(0, "Non-hexadecimal character");
        }
}
```

instead return an ubyte?

I have no conclusive answer:

- From an ABI PoV that does not matter, it's AL vs EAX , i.e same "parent" register. - From a self-documenting PoV I'd use ubyte. But then you hit the problem of promotion of `ch - ...` and you have to cast each of them.

Reply via email to