Closed charlesstaats closed 7 months ago
Thanks for reporting this. Actually, the int
type in Asymptote is supposed to be the highest precision native integer (normally 64 bits) so for consistency, format should always enforce ll
. In fact, an explicit 'll' doesn't really make sense from the point of view of the Asymptote machine (which, except for the bitwise functions AND, OR, XOR, NOT, CLZ, and CTZ pretends to be unaware of bit representations). So the desired behavour should be:
format("%x",intMax); 7ffffffffffffffd
format("%x",intMin); 8000000000000000
format("%d",intMax); 9223372036854775805
format("%d",intMin); -9223372036854775808
In fact the current version of Asymptote tries to turn 1 trillion dollars into a huge loss: format("$%'d",1000000000000); $-727,379,968
With commit 488d80962c76cc60629f590e34b350459ea59621, the correct result is produced: format("$%'d",1000000000000); $1,000,000,000,000
Example:
expected output:
7ffffffffffffffd
actual output:x
Note that the
'%x'
format string yieldsfffffffd
, which conforms to the standard but nevertheless might be surprising to some people (in particular, me before I did additional research).