++ed by:

1 non-PAUSE user.

Al Newkirk
and 1 contributors

# NAME

Bubblegum::Object::Number - Common Methods for Operating on Numbers

version 0.26

# SYNOPSIS

``````    use Bubblegum;

my \$number = 123456789;
say \$number->incr; # 123456790``````

# DESCRIPTION

Number methods work on data that meets the criteria for being a number. A number holds and manipulates an arbitrary sequence of bytes, typically representing numberic characters (0-9). It is not necessary to use this module as it is loaded automatically by the Bubblegum class.

# METHODS

## abs

``````    my \$number = 12;
\$number->abs; # 12

\$number = -12;
\$number->abs; # 12``````

The abs method returns the absolute value of the subject.

## atan2

``````    my \$number = 1;
\$number->atan2(1); # 0.785398163397448``````

The atan2 method returns the arctangent of Y/X in the range -PI to PI

## cos

``````    my \$number = 12;
\$number->cos; # 0.843853958732492``````

The cos method computes the cosine of the subject (expressed in radians).

## decr

``````    my \$number = 123456789;
\$number->decr; # 123456788``````

The decr method returns the numeric subject decremented by 1.

## exp

``````    my \$number = 0;
\$number->exp; # 1

\$number = 1;
\$number->exp; # 2.71828182845905

\$number = 1.5;
\$number->exp; # 4.48168907033806``````

The exp method returns e (the natural logarithm base) to the power of the subject.

## hex

``````    my \$number = 175;
\$number->hex; # 0xaf``````

The hex method returns a hex string representing the value of the subject.

## incr

``````    my \$number = 123456789;
\$number->incr; # 123456790``````

The incr method returns the numeric subject incremented by 1.

## int

``````    my \$number = 12.5;
\$number->int; # 12``````

The int method returns the integer portion of the subject. Do not use this method for rounding.

## log

``````    my \$number = 12345;
\$number->log; # 9.42100640177928``````

The log method returns the natural logarithm (base e) of the subject.

## mod

``````    my \$number = 12;
\$number->mod(1); # 0
\$number->mod(2); # 0
\$number->mod(3); # 0
\$number->mod(4); # 0
\$number->mod(5); # 2``````

The mod method returns the division remainder of the subject divided by the argment.

## neg

``````    my \$number = 12345;
\$number->neg; # -12345``````

The neg method returns a negative version of the subject.

## pow

``````    my \$number = 12345;
\$number->pow(3); # 1881365963625``````

The pow method returns a number, the result of a math operation, which is the subject to the power of the argument.

## sin

``````    my \$number = 12345;
\$number->sin; # -0.993771636455681``````

The sin method returns the sine of the subject (expressed in radians).

## sqrt

``````    my \$number = 12345;
\$number->sqrt; # 111.108055513541``````

The sqrt method returns the positive square root of the subject.

## to_array

``````    my \$int = 1;
\$int->to_array; # [1]``````

The to_array method is used for coercion and simply returns an array reference where the first element contains the subject.

## to_code

``````    my \$int = 1;
\$int->to_code; # sub { 1 }``````

The to_code method is used for coercion and simply returns a code reference which always returns the subject when called.

## to_hash

``````    my \$int = 1;
\$int->to_hash; # { 1 => 1 }``````

The to_hash method is used for coercion and simply returns a hash reference with a single key and value, having the key and value both contain the subject.

## to_integer

``````    my \$int = 1;
\$int->to_integer; # 1``````

The to_integer method is used for coercion and simply returns the subject.

## to_string

``````    my \$int = 1;
\$int->to_string; # '1'``````

The to_string method is used for coercion and simply returns the stringified version of the subject.