Relation:format

Adds a number format to a column. Formatted columns are right-aligned.

Description

format name formatstring (, name formatstring ...)

Parameters

  • formatstring: formats as defined in sprintf extended with
    • n numberformat with space thousands separator
    • N numberformat with single quote thousands separator
    • p percentage
    • P percentage with space inserted before percentage sign

Examples

formatstring 0.255 5.2 6.8 -81 89080
"%d" 0 5 7 -81 89080
"%1.3f" 0.255 5.200 6.800 -81.000 89080.000
"%1.0n" 0 5 7 -81 89 080
"%1p" 26% 520% 680% 81000% 8908000

Comments

The format does not change the values. It is just displayed when you print or write to a file.

When you calculate with tables, format may get lost. Use this instruction just before you print or write.

The format does round.

You can also use the format() function to change the value definitively.

See also

print