It looks to me as if Jess and gcc are consistent in this regard:
[ejfried@asllinux tmp]$ cat > foo.c
main() {
printf("%04d\n", 10);
printf("%4d\n", 10);
}
[ejfried@asllinux tmp]$ gcc foo.c
[ejfried@asllinux tmp]$ ./a.out
0010
10
[ejfried@asllinux src]$ java jess.Main
Jess, the Java Expert System Shell
Copyright (C) 2001 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.1a4 8/30/2002
Jess> (format nil "%04d" 10)
"0010"
Jess> (format nil "%4d" 10)
" 10"
Furthermore, K&R, 2nd Ed, p. 243, seems to agree that the "0" is
required to get padding with zeroes.
I think Ruff, Jeff wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> You recently answered a question about changes in "format" with the new
> release as shown in the text below.
>
> "If you want to print the number as an integer in a four-digit field,"
> "then convert it to an integer using the (integer) function first:"
>
> "(format nil "%04d" (integer ( * (fetch TopPad) 1.0E-4)))"
>
> When I tried to use the following
>
> (bind ?pos4-11 (format nil "%4d" (integer (* (fetch TopPad) 0.001))))
>
> for a TopPad value of 502500, I do not get the expected [per Unix man
> pages] addition of "0" added to the left.
>
> Expected 0502
>
> Received " "502.
>
> Sometimes the value for TopPad will have 4 digits, sometimes it will
> have 3. Must I check the length and pad on my own?
>
> Thanks
> Jeff Ruff
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> --------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------