gval icon indicating copy to clipboard operation
gval copied to clipboard

Hexadecimal support

Open jotego opened this issue 2 years ago • 2 comments

Thank you for this great package.

It would be nice if 0x for hexadecimal numbers was usable by default. I think the way around it now is to define some sort of hex function within the application.

jotego avatar Jun 02 '23 14:06 jotego

Pretty sure the core tokenization logic supports it since it goes through scanner.Int. However parseNumber doesn't deal with it -- you could change that to fallback on strconv.ParseInt with a base of 0. (Just saying this based on glancing at the code, didn't do any actual tests.)

imirkin avatar Jun 09 '23 16:06 imirkin

Worth noting that gval's base/arithmetic language can't represent actual integers, only float64's. You'll run into precision issues once you go above 1<<53 in magnitude. But of course you could specify a language based on int64's, see e.g. how decimal is handled.

imirkin avatar Jun 09 '23 16:06 imirkin