aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-Num.percent.3
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-27 16:49:38 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-27 16:49:38 -0400
commitbaf990e65c62f42e45fe25ac385db9536d3f1788 (patch)
tree7b89cecde1d6cd3b600b9295e0ad22a702cd1065 /man/man3/tomo-Num.percent.3
parent1a8a8bc3e2ebd9c282db8131902f9bb5de8c03cb (diff)
Update stdlib to use `print` instead of `printf` in all cases. This
means bringing in fpconv to do float-to-string conversion and a few updates to integer and number methods for string formatting.
Diffstat (limited to 'man/man3/tomo-Num.percent.3')
-rw-r--r--man/man3/tomo-Num.percent.310
1 files changed, 7 insertions, 3 deletions
diff --git a/man/man3/tomo-Num.percent.3 b/man/man3/tomo-Num.percent.3
index ee092b53..33b78657 100644
--- a/man/man3/tomo-Num.percent.3
+++ b/man/man3/tomo-Num.percent.3
@@ -2,14 +2,14 @@
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
-.TH Num.percent 3 2025-04-21 "Tomo man-pages"
+.TH Num.percent 3 2025-04-27 "Tomo man-pages"
.SH NAME
Num.percent \- format as a percentage
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
-.BI Num.percent\ :\ func(n:\ Num,\ precision:\ Int\ =\ 0\ ->\ Text)
+.BI Num.percent\ :\ func(n:\ Num,\ precision:\ Num\ =\ 0.01\ ->\ Text)
.fi
.SH DESCRIPTION
Convert a number into a percentage text with a percent sign.
@@ -23,7 +23,7 @@ lb lb lbx lb
l l l l.
Name Type Description Default
n Num The number to be converted to a percent. -
-precision Int The number of decimal places. Default is `0`. 0
+precision Num Round the percentage to this precision level. 0.01
.TE
.SH RETURN
A text representation of the number as a percentage with a percent sign.
@@ -34,4 +34,8 @@ A text representation of the number as a percentage with a percent sign.
= "50%"
>> (1./3.).percent(2)
= "33.33%"
+>> (1./3.).percent(2, precision=0.0001)
+= "33.3333%"
+>> (1./3.).percent(2, precision=10.)
+= "30%"
.EE