<< print Sorties Xcos >>

Scilab Help >> Sorties > printf_conversion

printf_conversion

mprintf, msprintf, mfprintf conversion specifications

Description

Each conversion specification in the mprintf , msprintf , mfprintf format parameter has the following syntax:

A field width or precision can be indicated by an * (asterisk) instead of a digit string. In this case, an integer value parameter supplies the field width or precision. The value parameter converted for output is not fetched until the conversion letter is reached, so the parameters specifying field width or precision must appear before the value to be converted (if any).

If the result of a conversion is wider than the field width, the field is expanded to contain the converted result.

The representation of the plus sign depends on whether the + or (space) formatting option is specified.

display of exponential form %e is platform dependent with a different number of digits in exponent.

Platform Example: msprintf("%e",1.23e4)
Windows 1.23000e+004
Linux/Mac OS 1.23000e+04

Examples

mprintf('a string: %s\n', 'Scilab');
mprintf('an integer: %d\n', 10);
mprintf('an integer: %4d\n', 10);
mprintf('a left justified integer: %-4d\n', 10);
mprintf('an integer converted to float: %#fd\n',10);
mprintf('an integer with a sign: %+4d\n', 10);
mprintf('an integer with a sign: %+4d\n', -10);
mprintf('an integer padded with zeros: %04d\n', 10);
mprintf('an unsigned integer: %u\n', 10);
mprintf('an unsigned integer: %4u\n', -10);
mprintf('an integer converted to hexadecimal: %x\n', 10);
mprintf('a float: %d\n', %pi);
mprintf('a float: %3.2d\n', %pi);
mprintf('a float (exponential form): %3.2e\n', %pi);
mprintf('a float (exponential form): %3.2g\n', %pi);
mprintf('a character: %c\n', 'a');
mprintf('a character: %c\n', 'aaa');

See also


Report an issue
<< print Sorties Xcos >>