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:

Venus::Kind::Value

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 1
# given: synopsis;

my $abs = $number->abs;

# 1000
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

add

add(Num $value) (Num)

The add method returns the result of addition performed on the argument provided.

Since 1.23

add example 1
# given: synopsis;

my $add = $number->add(1_000);

# 2000

append

append(Str @parts) (Str)

The append method appends arugments to the number.

Since 1.23

append example 1
# given: synopsis;

my $append = $number->append(0);

# 10_000

append_with

append_with(Str $delimiter, Str @parts) (Str)

The append_with method appends arugments to the number using the delimiter provided.

Since 1.23

append_with example 1
# given: synopsis;

my $append = $number->append_with('.', 0);

# "1000.0"

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

cast

cast(Str $kind) (Object | Undef)

The cast method converts "value" objects between different "value" object types, based on the name of the type provided. This method will return undef if the invocant is not a Venus::Kind::Value.

Since 0.08

cast example 1
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('array');

# bless({ value => [0] }, "Venus::Array")
cast example 2
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('boolean');

# bless({ value => 0 }, "Venus::Boolean")
cast example 3
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('code');

# bless({ value => sub { ... } }, "Venus::Code")
cast example 4
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('float');

# bless({ value => "0.0" }, "Venus::Float")
cast example 5
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('hash');

# bless({ value => { "0" => 0 } }, "Venus::Hash")
cast example 6
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('number');

# bless({ value => 0 }, "Venus::Number")
cast example 7
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('regexp');

# bless({ value => qr/(?^u:0)/ }, "Venus::Regexp")
cast example 8
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('scalar');

# bless({ value => \0 }, "Venus::Scalar")
cast example 9
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('string');

# bless({ value => 0 }, "Venus::String")
cast example 10
package main;

use Venus::Number;

my $number = Venus::Number->new;

my $cast = $number->cast('undef');

# bless({ value => undef }, "Venus::Undef")

concat

concat(Str @parts) (Str)

The concat method returns the number with the argument list appended to it.

Since 1.23

concat example 1
package main;

use Venus::Number;

my $number = Venus::Number->new(1_000);

my $concat = $number->concat('.', '0001');

# "1000.0001"

contains

contains(Str $expr) (Bool)

The contains method searches the number for a substring or expression returns true or false if found.

Since 1.23

contains example 1
package main;

use Venus::Number;

my $number = Venus::Number->new(1_0001);

my $contains = $number->contains(10);

# 1
contains example 2
package main;

use Venus::Number;

my $number = Venus::Number->new(1_0001);

my $contains = $number->contains(2);

# 0
contains example 3
package main;

use Venus::Number;

my $number = Venus::Number->new(1_0001);

my $contains = $number->contains(qr/01$/);

# 1

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() (Num)

The default method returns the default value, i.e. 0.

Since 0.01

default example 1
# given: synopsis;

my $default = $number->default;

# 0

div

div(Num $value) (Num)

The div method returns the result of division performed on the argument provided.

Since 1.23

div example 1
# given: synopsis;

my $div = $number->div(2);

# 500

eq

eq(Any $arg) (Bool)

The eq method performs an "equals" operation using the argument provided.

Since 0.08

eq example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->eq($rvalue);

# 0
eq example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->eq($rvalue);

# 0
eq example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->eq($rvalue);

# 1
eq example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->eq($rvalue);

# 0
eq example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->eq($rvalue);

# 1
eq example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->eq($rvalue);

# 0
eq example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->eq($rvalue);

# 0
eq example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->eq($rvalue);

# 1
eq example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->eq($rvalue);

# 1

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

ge

ge(Any $arg) (Bool)

The ge method performs a "greater-than-or-equal-to" operation using the argument provided.

Since 0.08

ge example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->ge($rvalue);

# 0
ge example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->ge($rvalue);

# 0
ge example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->ge($rvalue);

# 1
ge example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->ge($rvalue);

# 0
ge example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->ge($rvalue);

# 1
ge example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->ge($rvalue);

# 0
ge example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->ge($rvalue);

# 0
ge example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->ge($rvalue);

# 1
ge example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->ge($rvalue);

# 1

gele

gele(Any $arg1, Any $arg2) (Bool)

The gele method performs a "greater-than-or-equal-to" operation on the 1st argument, and "lesser-than-or-equal-to" operation on the 2nd argument.

Since 0.08

gele example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->gele($rvalue);

# 0
gele example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->gele($rvalue);

# 0
gele example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->gele($rvalue);

# 1
gele example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->gele($rvalue);

# 0
gele example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->gele($rvalue);

# 1
gele example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->gele($rvalue);

# 0
gele example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->gele($rvalue);

# 0
gele example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->gele($rvalue);

# 1
gele example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->gele($rvalue);

# 1

gt

gt(Any $arg) (Bool)

The gt method performs a "greater-than" operation using the argument provided.

Since 0.08

gt example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->gt($rvalue);

# 0
gt example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->gt($rvalue);

# 0

gtlt

gtlt(Any $arg1, Any $arg2) (Bool)

The gtlt method performs a "greater-than" operation on the 1st argument, and "lesser-than" operation on the 2nd argument.

Since 0.08

gtlt example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->gtlt($rvalue);

# 0
gtlt example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->gtlt($rvalue);

# 0

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

index

index(Str $substr, Int $start) (Num)

The index method searches for the argument within the number and returns the position of the first occurrence of the argument.

Since 1.23

index example 1
package main;

use Venus::Number;

my $number = Venus::Number->new(1_0001);

my $index = $number->index(0);

# 1
index example 2
package main;

use Venus::Number;

my $number = Venus::Number->new(1_0001);

my $index = $number->index(1, 1);

# 4
index example 3
package main;

use Venus::Number;

my $number = Venus::Number->new(1_0001);

my $index = $number->index(2);

# -1

int

int() (Num)

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

le

le(Any $arg) (Bool)

The le method performs a "lesser-than-or-equal-to" operation using the argument provided.

Since 0.08

le example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->le($rvalue);

# 1
le example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->le($rvalue);

# 1
le example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->le($rvalue);

# 1
le example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->le($rvalue);

# 1
le example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->le($rvalue);

# 1
le example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->le($rvalue);

# 1
le example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->le($rvalue);

# 1
le example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->le($rvalue);

# 1
le example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->le($rvalue);

# 1

length

length() (Num)

The length method returns the number of characters within the number.

Since 1.23

length example 1
# given: synopsis;

my $length = $number->length;

# 4

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

lshift

lshift(Num $value) (Num)

The lshift method returns the result of a left shift performed on the argument provided.

Since 1.23

lshift example 1
# given: synopsis;

my $lshift = $number->lshift(2);

# 4000

lt

lt(Any $arg) (Bool)

The lt method performs a "lesser-than" operation using the argument provided.

Since 0.08

lt example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->lt($rvalue);

# 1
lt example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->lt($rvalue);

# 1
lt example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->lt($rvalue);

# 0
lt example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->lt($rvalue);

# 1
lt example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->lt($rvalue);

# 0
lt example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->lt($rvalue);

# 1
lt example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->lt($rvalue);

# 1
lt example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->lt($rvalue);

# 0
lt example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->lt($rvalue);

# 0

mod

mod() (Num)

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

multi

multi(Num $value) (Num)

The multi method returns the result multiplication performed on the argument provided.

Since 1.23

multi example 1
# given: synopsis;

my $multi = $number->multi(2);

# 2000

ne

ne(Any $arg) (Bool)

The ne method performs a "not-equal-to" operation using the argument provided.

Since 0.08

ne example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->ne($rvalue);

# 1
ne example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->ne($rvalue);

# 1
ne example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->ne($rvalue);

# 0
ne example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->ne($rvalue);

# 1
ne example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->ne($rvalue);

# 0
ne example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->ne($rvalue);

# 1
ne example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->ne($rvalue);

# 1
ne example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->ne($rvalue);

# 0
ne example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->ne($rvalue);

# 0

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

numified

numified() (Num)

The numified method returns the numerical representation of the object. For number objects this method returns the object's underlying value.

Since 0.08

numified example 1
# given: synopsis;

my $numified = $number->numified;

# 1000
numified example 2
package main;

use Venus::Number;

my $number = Venus::Number->new(2_000);

my $numified = $number->numified;

# 2000
numified example 3
package main;

use Venus::Number;

my $number = Venus::Number->new(10_000);

my $numified = $number->numified;

# 10000

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

prepend

prepend(Str @parts) (Str)

The prepend method prepends arugments to the number.

Since 1.23

prepend example 1
# given: synopsis;

my $prepend = $number->prepend(1);

# 11_000

prepend_with

prepend_with(Str $delimiter, Str @parts) (Str)

The prepend_with method prepends arugments to the number using the delimiter provided.

Since 1.23

prepend_with example 1
# given: synopsis;

my $prepend = $number->prepend_with('.', '11');

# "11.1000"

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]

repeat

repeat(Num $number, Str $delimiter) (Str)

The repeat method repeats the number value N times based on the argument provided and returns a new concatenated number. Optionally, a delimiter can be provided and be place between the occurences.

Since 1.23

repeat example 1
package main;

use Venus::Number;

my $number = Venus::Number->new('999');

my $repeat = $number->repeat(2);

# 999999
repeat example 2
package main;

use Venus::Number;

my $number = Venus::Number->new('999');

my $repeat = $number->repeat(2, '.');

# 999.999

rshift

rshift(num $value) (Num)

The rshift method returns the result a right shift performed on the argument provided.

Since 1.23

rshift example 1
# given: synopsis;

my $rshift = $number->rshift(2);

# 250

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

sub

sub(Num $value) (Num)

The sub method returns the result subtraction performed on the argument provided.

Since 1.23

sub example 1
# given: synopsis;

my $sub = $number->sub(500);

# 500

substr

substr(Num $offset, Num $length, Str $replace) (Str)

The substr method calls the core "substr" function with the object's number value. In list context returns the result and the subject.

Since 1.23

substr example 1
package main;

use Venus::Number;

my $number = Venus::Number->new(1234567890);

my $substr = $number->substr(0, 5);

# 12345
substr example 2
package main;

use Venus::Number;

my $number = Venus::Number->new(1234567890);

my $substr = $number->substr(6, 5);

# 7890
substr example 3
package main;

use Venus::Number;

my $number = Venus::Number->new(1234567890);

my $substr = $number->substr(6, 5, '0000');

# "1234560000"
substr example 4
package main;

use Venus::Number;

my $number = Venus::Number->new(1234567890);

my ($result, $subject) = $number->substr(6, 5, '0000');

# ("789", "1234560000")

tv

tv(Any $arg) (Bool)

The tv method performs a "type-and-value-equal-to" operation using argument provided.

Since 0.08

tv example 1
package main;

use Venus::Array;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Array->new;

my $result = $lvalue->tv($rvalue);

# 0
tv example 2
package main;

use Venus::Code;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Code->new;

my $result = $lvalue->tv($rvalue);

# 0
tv example 3
package main;

use Venus::Float;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Float->new;

my $result = $lvalue->tv($rvalue);

# 1
tv example 4
package main;

use Venus::Hash;
use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Hash->new;

my $result = $lvalue->tv($rvalue);

# 0
tv example 5
package main;

use Venus::Number;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Number->new;

my $result = $lvalue->tv($rvalue);

# 1
tv example 6
package main;

use Venus::Number;
use Venus::Regexp;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Regexp->new;

my $result = $lvalue->tv($rvalue);

# 0
tv example 7
package main;

use Venus::Number;
use Venus::Scalar;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Scalar->new;

my $result = $lvalue->tv($rvalue);

# 0
tv example 8
package main;

use Venus::Number;
use Venus::String;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::String->new;

my $result = $lvalue->tv($rvalue);

# 0
tv example 9
package main;

use Venus::Number;
use Venus::Undef;

my $lvalue = Venus::Number->new;
my $rvalue = Venus::Undef->new;

my $result = $lvalue->tv($rvalue);

# 0

AUTHORS

Awncorp, awncorp@cpan.org

LICENSE

Copyright (C) 2000, Al Newkirk.

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.