[MLton-devel] Int-inf shifts

Stephen Weeks MLton@mlton.org
Thu, 31 Oct 2002 16:58:45 -0800


> One other IntInf note; Word.fmt StringCvt.HEX will print out
> hex-digits in upper-case, while IntInf_do_toString in hex will use
> lower-case.  Should they be unified?  And, if so, who should change?
> In IntInf.c, it would be easy enough, I guess, to run over the
> string and lower-case the elements.

The spec for fmt for both INTEGER and WORD says "The hexadecimal
digits 10-15 are represented as [A-F]".  So, if IntInf.fmt is using
lowercase, it is wrong.  I just did a simple test, and I see that it
is.  It works for small integers because it uses a separate routine,
but fails when it invokes do_toString.

% cat z.sml
val _ = print (concat [IntInf.fmt StringCvt.HEX 0x12AB, "\n"])
val _ = print (concat [IntInf.fmt StringCvt.HEX (0x12AB * 0x100000), "\n"])
val _ = print (concat [IntInf.fmt StringCvt.HEX 0x12AB34CD56EF, "\n"])
tmp% mlton z.sml && ./z
12AB
12ab00000
12ab34cd56ef

Hmmm, there also appears to be a separate, unrelated, optimizer bug,
since the following program is completely broken.

% cat z.sml
val _ = print (concat [IntInf.fmt StringCvt.HEX 0x12AB, "\n"])
val _ = print (concat [IntInf.fmt StringCvt.HEX 0x12AB34CD56EF, "\n"])
% mlton z.sml && ./z
12AB
20526534579951


-------------------------------------------------------
This sf.net email is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel