vault backup: 2024-09-11 12:21:34
This commit is contained in:
parent
4519740ea7
commit
1aab5e8e9c
@ -27,10 +27,13 @@ A variable must be declared before it is assigned.
|
||||
|
||||
|
||||
# Formatting specifiers
|
||||
| Specifier | Function |
|
||||
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `%d` | Display an integer |
|
||||
| `%f` | Display a float. Specify the number of places to round to by adding a decimal and a number, eg `%.2f` would round to two decimal places. |
|
||||
# Standard library
|
||||
## Formatting specifiers
|
||||
| Specifier | Function |
|
||||
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `%d` | Decimal representation: Display a value as a base 10 (hence the decimal) integer. |
|
||||
| `%f` | Fixed point decimal representation. Specify the number of places to round to by adding a decimal and a number, eg `%.2f` would round to two decimal places. |
|
||||
| `%e` | |
|
||||
For number formatting specifiers, the convention is as follows:
|
||||
`%-a.bX`
|
||||
`%`: Start of the formatting specifier
|
||||
@ -38,5 +41,6 @@ For number formatting specifiers, the convention is as follows:
|
||||
`a`: (optional) If included, the size of the field in characters.
|
||||
`.`: Separator between `a` and `b`. Optional if `b` is not specified
|
||||
`b`: The number of decimal places to round to
|
||||
`X`: The type of format to use, and the end of the specifier. Use `d` for integer base 10 (decimal) representation, `f` for fixed point decimal, and `e` for exponential notation
|
||||
# Standard library
|
||||
`X`: The type of format to use, and the end of the specifier. Use `d` for integer base 10 (decimal) representation, `f` for fixed point decimal, and `e` for exponential notation, and `g` to select between fixed point and exponential, whichever is shorter.
|
||||
## `printf`
|
||||
Write a string to standard output. `f` indicates that it's a formatting string. The string will not include move the cursor to a newline, append `\n` to the end of the string to do so.
|
Loading…
Reference in New Issue
Block a user