[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
sprintf
function. pattern is a string contening conversion characters. Recognized conversion characters are :
%f
%e
%g
%f
or %e
. Here is a snapshot from the info
pages on printf()
:
The style used depends on the value convered; style %e
will be used only if the exponent resulting from the conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional part of the result; a decimal-point character appears only if it is followed by a digit…
%d
%.0f
, useful to format integers;
%p
point
, vector
, normal
) using the style [%f %f %f]
;
%c
%p
, but for colors;
%m
[%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f]
;
%s
Note that all conversion characters recognise the precision specifier.
EXAMPLE
/* Formats a float using exponential notation */ string expo = format( "%e", sqrt(27) ); /* Formats a float, with 5 decimals in the fractional part */ point p = sqrt(5); string precision5 = format( "p = %.5p", p ); /* Aligns text */ string aligned = format( "%20s", "align me please" ); |
format()
but prints the formatted string to `stdout' instead of returning a string.
regex
(21) expression.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |