NAME
Venus::Number - Number Class
ABSTRACT
Number Class for Perl 5
SYNOPSIS
package main;
use Venus::Number;
my $number = Venus::Number->new(1_000);
# $number->abs;
DESCRIPTION
This package provides methods for manipulating number data.
INHERITS
This package inherits behaviors from:
METHODS
This package provides the following methods:
abs
abs() (Num)
The abs method returns the absolute value of the number.
Since 0.01
- abs example 2
-
package main; use Venus::Number; my $number = Venus::Number->new(12); my $abs = $number->abs; # 12
- abs example 3
-
package main; use Venus::Number; my $number = Venus::Number->new(-12); my $abs = $number->abs; # 12
atan2
atan2() (Num)
The atan2 method returns the arctangent of Y/X in the range -PI to PI.
Since 0.01
- atan2 example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(1); my $atan2 = $number->atan2(1); # 0.785398163397448
cos
cos() (Num)
The cos method computes the cosine of the number (expressed in radians).
Since 0.01
- cos example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12); my $cos = $number->cos; # 0.843853958732492
decr
decr() (Num)
The decr method returns the numeric number decremented by 1.
Since 0.01
- decr example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(123456789); my $decr = $number->decr; # 123456788
- decr example 2
-
package main; use Venus::Number; my $number = Venus::Number->new(123456789); my $decr = $number->decr(123456788); # 1
default
default() (Int)
The default method returns the default value, i.e. 0
.
Since 0.01
exp
exp() (Num)
The exp method returns e (the natural logarithm base) to the power of the number.
Since 0.01
- exp example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(0); my $exp = $number->exp; # 1
- exp example 2
-
package main; use Venus::Number; my $number = Venus::Number->new(1); my $exp = $number->exp; # 2.71828182845905
- exp example 3
-
package main; use Venus::Number; my $number = Venus::Number->new(1.5); my $exp = $number->exp; # 4.48168907033806
hex
hex() (Str)
The hex method returns a hex string representing the value of the number.
Since 0.01
- hex example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(175); my $hex = $number->hex; # "0xaf"
incr
incr() (Num)
The incr method returns the numeric number incremented by 1.
Since 0.01
- incr example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(123456789); my $incr = $number->incr; # 123456790
- incr example 2
-
package main; use Venus::Number; my $number = Venus::Number->new(123456790); my $incr = $number->incr(-1); # 123456789
int
int() (Int)
The int method returns the integer portion of the number. Do not use this method for rounding.
Since 0.01
- int example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12.5); my $int = $number->int; # 12
log
log() (Num)
The log method returns the natural logarithm (base e) of the number.
Since 0.01
- log example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12345); my $log = $number->log; # 9.42100640177928
mod
mod() (Int)
The mod method returns the division remainder of the number divided by the argment.
Since 0.01
- mod example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12); my $mod = $number->mod(1); # 0
- mod example 2
-
package main; use Venus::Number; my $number = Venus::Number->new(12); my $mod = $number->mod(2); # 0
- mod example 3
-
package main; use Venus::Number; my $number = Venus::Number->new(12); my $mod = $number->mod(5); # 2
neg
neg() (Num)
The neg method returns a negative version of the number.
Since 0.01
- neg example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12345); my $neg = $number->neg; # -12345
pow
pow() (Num)
The pow method returns a number, the result of a math operation, which is the number to the power of the argument.
Since 0.01
- pow example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12345); my $pow = $number->pow(3); # 1881365963625
range
range() (ArrayRef)
The range method returns an array reference containing integer increasing values up-to or down-to the limit specified.
Since 0.01
- range example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(5); my $range = $number->range(9); # [5..9]
- range example 2
-
package main; use Venus::Number; my $number = Venus::Number->new(5); my $range = $number->range(1); # [5, 4, 3, 2, 1]
sin
sin() (Num)
The sin method returns the sine of the number (expressed in radians).
Since 0.01
- sin example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12345); my $sin = $number->sin; # -0.993771636455681
sqrt
sqrt() (Num)
The sqrt method returns the positive square root of the number.
Since 0.01
- sqrt example 1
-
package main; use Venus::Number; my $number = Venus::Number->new(12345); my $sqrt = $number->sqrt; # 111.108055513541
OPERATORS
This package overloads the following operators:
- operation:
(!)
-
This package overloads the
!
operator.example 1
# given: synopsis; my $result = $number = !$number; # ""
- operation:
(!=)
-
This package overloads the
!=
operator.example 1
# given: synopsis; my $result = $number != 100; # 1
- operation:
(%)
-
This package overloads the
%
operator.example 1
# given: synopsis; my $result = $number % 2_000; # 1_000
- operation:
(*)
-
This package overloads the
*
operator.example 1
# given: synopsis; my $result = $number * 2; # 2_000
- operation:
(+)
-
This package overloads the
+
operator.example 1
# given: synopsis; my $result = $number + 100; # 1100
- operation:
(-)
-
This package overloads the
-
operator.example 1
# given: synopsis; my $result = $number - 100; # 900
- operation:
(.)
-
This package overloads the
.
operator.example 1
# given: synopsis; my $result = $number . 0; # 10_000
- operation:
(/)
-
This package overloads the
/
operator.example 1
# given: synopsis; my $result = $number / 10; # 100
- operation:
(0+)
-
This package overloads the
0+
operator.example 1
# given: synopsis; my $result = $number + 0; # 1_000
- operation:
(<)
-
This package overloads the
<
operator.example 1
# given: synopsis; my $result = $number < 1001; # 1
- operation:
(<=)
-
This package overloads the
<=
operator.example 1
# given: synopsis; my $result = $number <= 1000; # 1
- operation:
(==)
-
This package overloads the
==
operator.example 1
# given: synopsis; my $result = $number == 1000; # 1
- operation:
(
)> -
This package overloads the
> operator.
example 1
# given: synopsis; my $result = $number > 999; # 1
- operation:
(
=)> -
This package overloads the
=> operator.
example 1
# given: synopsis; my $result = $number >= 1000; # 1
- operation:
(bool)
-
This package overloads the
bool
operator.example 1
# given: synopsis; my $result = !!$number; # 1
- operation:
(eq)
-
This package overloads the
eq
operator.example 1
# given: synopsis; my $result = $number eq "1000"; # 1
- operation:
(ne)
-
This package overloads the
ne
operator.example 1
# given: synopsis; my $result = $number ne "1_000"; # 1
- operation:
(qr)
-
This package overloads the
qr
operator.example 1
# given: synopsis; my $result = '1000' =~ qr/$number/; # 1
- operation:
(x)
-
This package overloads the
x
operator.example 1
# given: synopsis; my $result = $number x 2; # 10001000
AUTHORS
Cpanery, cpanery@cpan.org
LICENSE
Copyright (C) 2021, Cpanery
Read the "license" file.