Skip to content

Commit

Permalink
Merge pull request #9 from chdesvages/main
Browse files Browse the repository at this point in the history
Added type 'g' examples for floating point formatting
  • Loading branch information
treyhunner committed Mar 2, 2023
2 parents 109fe9d + e4f8ccd commit eb2cd9b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cheat.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ The below examples assume the following variables:
| `'4,125.60'` | `{number:,.2f}` | | | `,` | `.2` | `f` |
| `'04125.60'` | `{number:08.2f}` | `0` | `8` | | `.2` | `f` |
| `' 4125.60'` | `{number: 8.2f}` | ` ` | `8` | | `.2` | `f` |
| `'4.1e+03'` | `{number:.2g}` | | | | `.2` | `g` |
| `'4125.6'` | `{number:.8g}` | | | | `.8` | `g` |
| `'37%'` | `{percent:.0%}` | | | | `.0` | `%` |

These format specifications only work on all numbers (both `int` and `float`).

- Type `f` with precision `.n` displays `n` digits after the decimal point.
- Type `g` with precision `.n` displays `n` significant digits in scientific notation. Trailing zeros are not displayed.


## Integers

Expand Down

0 comments on commit eb2cd9b

Please sign in to comment.