Some cleanup of printf and better docs.

db4
John Benediktsson 2008-09-22 19:39:27 -07:00
parent 0240427ab3
commit 388bf88d0f
2 changed files with 11 additions and 1 deletions

View File

@ -39,7 +39,9 @@ HELP: sprintf
{ $see-also printf } ; { $see-also printf } ;
ARTICLE: "printf" "Formatted printing" ARTICLE: "printf" "Formatted printing"
"The " { $vocab-link "printf" } " and " { $vocab-link "sprintf" } " words are used for formatted printing.\n" "The " { $vocab-link "printf" } " vocabulary is used for formatted printing.\n"
{ $subsection printf }
{ $subsection sprintf }
"\n" "\n"
"Several format specifications exist for handling arguments of different types, and specifying attributes for the result string, including such things as maximum width, padding, and decimals.\n" "Several format specifications exist for handling arguments of different types, and specifying attributes for the result string, including such things as maximum width, padding, and decimals.\n"
{ $table { $table
@ -72,3 +74,7 @@ ARTICLE: "printf" "Formatted printing"
"\"%.10f\" formats a float to pad-right with zeros up to 10 digits beyond the decimal point." "\"%.10f\" formats a float to pad-right with zeros up to 10 digits beyond the decimal point."
"\"%.5E\" formats a float into scientific notation with zeros up to 5 digits beyond the decimal point, but before the exponent." "\"%.5E\" formats a float into scientific notation with zeros up to 5 digits beyond the decimal point, but before the exponent."
} ; } ;
ABOUT: "printf"

View File

@ -7,6 +7,10 @@ USING: kernel printf tools.test ;
[ "%s" sprintf ] must-infer [ "%s" sprintf ] must-infer
[ t ] [ "" "" sprintf = ] unit-test
[ t ] [ "asdf" "asdf" sprintf = ] unit-test
[ t ] [ "10" 10 "%d" sprintf = ] unit-test [ t ] [ "10" 10 "%d" sprintf = ] unit-test
[ t ] [ "+10" 10 "%+d" sprintf = ] unit-test [ t ] [ "+10" 10 "%+d" sprintf = ] unit-test