summary refs log tree commit diff stats
path: root/lib/pure/strutils.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure/strutils.nim')
-rw-r--r--lib/pure/strutils.nim10
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.} =