diff options
author | Fabian Keller <bluenote10@users.noreply.github.com> | 2017-11-07 08:07:25 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-11-07 08:07:25 +0100 |
commit | 7c588f2cc479fcde854c89e882fda38310a30153 (patch) | |
tree | 8917f53d37121c3fe94fad2ad94596c787dd51cb | |
parent | 40a6caeed86e0ed3740fa88fdc7b5aa2bb4a28d5 (diff) | |
download | Nim-7c588f2cc479fcde854c89e882fda38310a30153.tar.gz |
added doc examples for formatFloat (#6704)
-rw-r--r-- | lib/pure/strutils.nim | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 0b55e6b1d..5c07757cb 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -2007,6 +2007,16 @@ proc formatFloat*(f: float, format: FloatFormatMode = ffDefault, ## after the decimal point for Nim's ``float`` type. ## ## If ``precision == 0``, it tries to format it nicely. + ## + ## Examples: + ## + ## .. code-block:: nim + ## + ## let x = 123.456 + ## echo x.formatFloat() # 123.4560000000000 + ## echo x.formatFloat(ffDecimal, 4) # 123.4560 + ## echo x.formatFloat(ffScientific, 2) # 1.23e+02 + ## result = formatBiggestFloat(f, format, precision, decimalSep) proc trimZeros*(x: var string) {.noSideEffect.} = |