Re: Documentation and output of pretty_print()
- Posted by "Juergen Luethje" <j.lue at gmx.de> Sep 13, 2004
- 492 views
Pete Lomax wrote: > On Sun, 12 Sep 2004 23:39:54 +0200, Juergen Luethje <j.lue at gmx.de> > wrote: > >> Pete Lomax wrote: >>> I've uploaded a new version. >>> http://palacebuilders.pwp.blueyonder.co.uk/ppp.ZIP >> >> 1) does not work as I expected, so you targeted at *signed* 32-bit >> integers only? >> 3) loses the '-' sign. > Both should be ok now. I'm in a hurry now, and will try it out when I'm back home from work. I just realized that both Eu's printf() and pretty_print() also lose the '-' sign. And there probably is another problem. In order to be able to re-use an output from e.g.
printf(1, "%x", {a})
I think it's actually much better to use
printf(1, "#%x", {a})
so that the printed value still can be recognized as hex number. The problem arises with negative numbers. Currently, the '-' sign is lost, I think that's a bug. But when the minus sign wil be included in the output, using the suggested format, then there will be output strings such as
#-FF
This raises the error "hex number not formed correctly". Here is a small demo program:
include misc.e include ppp.e sequence fmt atom a a = -#80000000 -- smallest 32-bit integer fmt = "%x\n" printf(1, fmt, {a}) pretty_print(1, a, {0,3,1,78,fmt,fmt}) ppOpt({pp_IntFmt, fmt}) pp(a) puts(1, "------------------------------\n") fmt = "#%x\n" printf(1, fmt, {a}) pretty_print(1, a, {0,3,1,78,fmt,fmt}) ppOpt({pp_IntFmt, fmt}) pp(a)
So what to do now? Regards, Juergen