Skip to content

Commit ae7cf35

Browse files
committed
Define .narrow method to narrow numeric types
Can narrow either Rat or Num to Int, for instance. Resolves #47.
1 parent d519b6f commit ae7cf35

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

S32-setting-library/Numeric.pod

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ DRAFT: Synopsis 32: Setting Library - Numeric
1919

2020
Created: 19 Mar 2009 extracted from S29-functions.pod
2121

22-
Last Modified: 29 May 2013
23-
Version: 17
22+
Last Modified: 28 Dec 2013
23+
Version: 18
2424

2525
The document is a draft.
2626

@@ -205,6 +205,15 @@ Convert from C<$base> to radians.
205205

206206
Convert from radians to C<$base>.
207207

208+
=item narrow
209+
210+
multi method narrow ( Numeric $x: ) is export
211+
212+
Attempts to coerce the number to the narrowest type that can represent it accurately;
213+
for instance, a C<Rat> with a denominator of 1 maybe be coerced to an C<Int> instead;
214+
an integral C<Num> may likewise turn into an C<Int>. (Neither C<Num> nor C<Rat> convert
215+
to each other, however.)
216+
208217
=back
209218

210219

0 commit comments

Comments
 (0)