opendylan icon indicating copy to clipboard operation
opendylan copied to clipboard

%b formatter outputs hex constant

Open cgay opened this issue 5 years ago • 3 comments

OD 2020.1, 64-bit Linux

format-out("%d", -9223372036854775808) produces no compiler warning and outputs #exFFFFFFFFFFFFFFFF8000000000000000.

I'm not even sure what #ex... is, but I'm pretty sure it's not a decimal number.

(That numeric constant is -2^63 and doesn't fit in 62 bits.)

cgay avatar Nov 24 '20 21:11 cgay

Same output for %b.

It seems like there are two things here. The constant should be flagged as not fitting in an <integer> and whatever that currently ends up turning into (a machine word?) the formatters should signal an error if they can't handle it, or they could do what Go does and output something indicating a bad input: !%d<the output as rendered by %=>

cgay avatar Nov 24 '20 21:11 cgay

#e is from Gwydion, representing <extended-integer> (bignums), and is (I think) representing a <double-integer> in this case.

housel avatar Nov 24 '20 21:11 housel

https://github.com/dylan-lang/opendylan/blob/41c98f02cbe184efb6575c82c95565bf03f21a17/sources/io/format.dylan#L267

cgay avatar Nov 26 '20 21:11 cgay