Skip to content

Commit

Permalink
Simplify the float printing docs a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo authored Feb 11, 2025
1 parent 6b15e95 commit e5d9ff0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions docs/lang/float.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,8 @@ Printing
--------

The [core `print` operation](./core.md#miscellaneous) prints `float` values with 17 decimal digits of precision, including trailing zeros.
(This is like using the `%.17lf` format specifier in C's `printf`.)
Float values switch to printing with exponential notation when the exponent's
magnitude is 10 or greater. This is printed with 17 decimal digits of precision
including zeros
and a `+` or `-` after `e` depending on the sign of the exponent. (This is
equivalent to `%.17e` with C's `printf` when `f.abs().log10().abs >= 10`)
For values with magnitude 10¹⁰, it uses exponential notation with suffixes like `e+12`.
(In terms of C's `printf`, this is like using the `%.17lf` format specifier for small values and `%.17e` for large values, i.e., when `f.abs().log10().abs >= 10`.)

Positive and negative zero, while they are equal according to `feq`, look different when printed.
Not-a-number values are printed as `NaN`; infinite values are printed as the strings `Infinity` or `-Infinity`.

0 comments on commit e5d9ff0

Please sign in to comment.