From 38ad1cc5125101407110ddb1df0b5089f19332b4 Mon Sep 17 00:00:00 2001 From: "David H. Adler" Date: Thu, 8 Oct 2015 14:56:55 -0400 Subject: [PATCH] Added usage statements to Numeric.pod --- doc/Type/Numeric.pod | 101 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/doc/Type/Numeric.pod b/doc/Type/Numeric.pod index 5078c6cdc..9ca44bd9f 100644 --- a/doc/Type/Numeric.pod +++ b/doc/Type/Numeric.pod @@ -25,38 +25,68 @@ generally return L in Perl 6. =head2 method Real +Defined as: + method Real(Numeric:D:) returns Real:D +Usage: + + NUMERIC.Real + If this C is equivalent to a C, return that C. Fail with C otherwise. =head2 method Int +Defined as: + method Int(Numeric:D:) returns Int:D +Usage: + + NUMERIC.Int + If this C is equivalent to a C, return the equivalent of calling C on that C to get an C. Fail with C otherwise. =head2 method Rat +Defined as: + method Rat(Numeric:D: Real $epsilon = 1.0e-6) returns Rat:D +Usage: + + NUMERIC.Rat + If this C is equivalent to a C, return a C which is within C<$epsilon> of that C's value. Fail with C otherwise. =head2 method Num +Defined as: + method Num(Numeric:D:) returns Num:D +Usage: + + NUMERIC.Num + If this C is equivalent to a C, return that C as a C as accurately as is possible. Fail with C otherwise. =head2 method narrow +Defined as: + method narrow(Numeric:D) returns Numeric:D +Usage: + + NUMERIC.narrow + Returns the number converted to the narrowest type that can hold it without loss of precision. @@ -65,51 +95,98 @@ loss of precision. =head2 method ACCEPTS +Defined as: + multi method ACCEPTS(Numeric:D: $other) +Usage: + + NUMERIC.ACCEPTS(OTHER) + Returns True if C<$other> is numerically the same as the invocant. =head2 routine log +Defined as: + multi sub log(Numeric:D, Numeric $base = e) returns Numeric:D multi method log(Numeric:D: Numeric $base = e) returns Numeric:D +Usage: + + log NUMERIC, NUMERIC? + NUMERIC.log(NUMERIC?) + Calculates the logarithm to base C<$base>. Defaults to the natural logarithm. =head2 routine log10 +Defined as: + multi sub log10(Numeric:D ) returns Numeric:D multi method log10(Numeric:D:) returns Numeric:D +Usage: + + log10 NUMERIC + NUMERIC.log10 + Calculates the logarithm to base 10. =head2 routine exp +Defined as: + multi sub exp(Numeric:D, Numeric:D $base = e) returns Numeric:D multi method exp(Numeric:D: Numeric:D $base = e) returns Numeric:D +Usage: + + exp NUMERIC, NUMERIC? + NUMERIC.exp(NUMERIC?) + Returns C<$base> to the power of the number, or C to the power of the number if called without a second argument. =head2 method roots +Defined as: + multi method roots(Numeric:D: Int:D $n) returns Positional +Usage: + + NUMERIC.roots(INTEGER) + Returns a list of the C<$n> complex roots, which evaluate to the original number when raised to the C<$n>th power. =head2 routine abs +Defined as: + multi sub abs(Numeric:D ) returns Real:D multi method abs(Numeric:D:) returns Real:D +Usage: + + abs NUMERIC + NUMERIC.abs + Returns the absolute value of the number. =head2 routine sqrt +Defined as: + multi sub sqrt(Numeric:D) returns Numeric:D multi method sqrt(Numeric:D) returns Numeric:D +Usage: + + sqrt NUMERIC + NUMERIC.sqrt + Returns a square root of the number. For real numbers the positive square root is returned. @@ -120,27 +197,51 @@ use the C method. =head2 method conj +Defined as: + multi method conj(Numeric:D) returns Numeric:D +Usage: + + NUMERIC.conj + Returns the complex conjugate of the number. Returns the number itself for real numbers. =head2 method Bool +Defined as: + multi method Bool(Numeric:D:) +Usage: + + NUMERIC.Bool + Returns C if the number is equivalent to zero, and C otherwise. =head2 method succ +Defined as: + method succ(Numeric:D:) +Usage: + + NUMERIC.succ + Returns the number incremented by one (successor). =head2 method pred +Defined as: + method pred(Numeric:D:) +Usage: + + NUMERIC.pred + Returns the number decremented by one (predecessor). =end pod