The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Math::BigNum::Inf - Represents the +/-Infinity value.

VERSION

Version 0.18

SYNOPSIS

    use Math::BigNum;
    say Math::BigNum->inf;         # => "inf"

    my $inf = Math::BigNum::Inf->new;
    say $inf->atan;                # => 1.57079632679489661923132169163975

DESCRIPTION

Math::BigNum::Inf is an abstract type that represents +/-Infinity.

SUBROUTINES/METHODS

new

    Inf->new                       # => Inf
    Inf->new('-')                  # => -Inf

Returns on objects representing the +/-Infinity abstract value.

neg

    $x->neg                        # => BigNum
    -$x                            # => BigNum

Negative value of $x. Returns abs($x) when $x is negative, otherwise returns -$x.

bneg

    $x->bneg                       # => BigNum

Negative value of $x, changing $x in-place.

abs

    $x->abs                        # => Inf

Absolute value of $x.

babs

    $x->babs                       # => Inf

Sets $x in-place to its absolute value.

copy

    $x->copy                       # => Inf

Returns a deep copy of the self object.

mone

    $x->mone                       # => BigNum

Returns a BigNum object which stores the value -1.

zero

    $x->zero                       # => BigNum

Returns a BigNum object which stores the value 0.

one

    $x->one                        # => BigNum

Returns a BigNum object which stores the value +1.

bmone

    $x->bmone                      # => BigNum

Promotes $x to a BigNum object which stores the value -1.

bzero

    $x->bzero                      # => BigNum

Promotes $x to a BigNum object which stores the value 0.

bone

    $x->bone                       # => BigNum

Promotes $x to a BigNum object which stores the value +1.

nan

    $x->nan                        # => Nan

Returns a Nan object, which stores the Not-a-Number value.

bnan

    $x->bnan                       # => Nan

Promotes $x to a Nan object.

inf

    $x->inf                        # => Inf

Returns an Inf object, which stores the +Infinity value.

ninf

    $x->ninf                       # => Inf

Returns an Inf object, which stores the -Infinity value.

binf

    $x->binf                       # => Inf

Changes $x in-place to +Infinity.

bninf

    $x->bninf                      # => Inf

Changes $x in-place to -Infinity.

add / iadd

    $x->add(BigNum)                # => Inf
    $x->add(Scalar)                # => Inf
    $x->add(Inf)                   # => Inf | Nan

    Scalar + Inf                   # => Inf
    Inf + BigNum                   # => Inf
    Inf + Scalar                   # => Inf
    Inf + Inf                      # => Inf | Nan

Addition of $x and $y.

badd / biadd

    $x->badd(BigNum)               # => Inf
    $x->badd(Scalar)               # => Inf
    $x->badd(Inf)                  # => Inf | Nan

    Inf += BigNum                  # => Inf
    Inf += Scalar                  # => Inf
    Inf += Inf                     # => Inf | Nan

Addition of $x and $y, changing $x in-place.

sub / isub

    $x->sub(BigNum)                # => Inf
    $x->sub(Scalar)                # => Inf
    $x->sub(Inf)                   # => Inf | Nan

    Scalar - Inf                   # => Inf
    Inf - BigNum                   # => Inf
    Inf - Scalar                   # => Inf
    Inf - Inf                      # => Inf | Nan

Subtraction of $x and $y.

bsub / bisub

    $x->bsub(BigNum)               # => Inf
    $x->bsub(Scalar)               # => Inf
    $x->bsub(Inf)                  # => Inf | Nan

    Inf -= BigNum                  # => Inf
    Inf -= Scalar                  # => Inf
    Inf -= Inf                     # => Inf | Nan

Subtraction of $x and $y, changing $x in-place.

mul / imul

    $x->mul(BigNum)                # => Inf | Nan
    $x->mul(Scalar)                # => Inf | Nan
    $x->mul(Inf)                   # => Inf

    Scalar * Inf                   # => Inf | Nan
    Inf * BigNum                   # => Inf | Nan
    Inf * Scalar                   # => Inf | Nan
    Inf * Inf                      # => Inf

Multiplication of $x and $y.

bmul / bimul

    $x->bmul(BigNum)               # => Inf | Nan
    $x->bmul(Scalar)               # => Inf | Nan
    $x->bmul(Inf)                  # => Inf

    Inf *= BigNum                  # => Inf | Nan
    Inf *= Scalar                  # => Inf | Nan
    Inf *= Inf                     # => Inf

Multiplication of $x and $y, changing $x in-place.

div / idiv

    $x->div(BigNum)                # => Inf
    $x->div(Scalar)                # => Inf
    $x->div(Inf)                   # => Nan

    Scalar / Inf                   # => BigNum(0)
    Inf / BigNum                   # => Inf
    Inf / Scalar                   # => Inf
    Inf / Inf                      # => Nan

Division of $x and $y.

bdiv / bidiv

    $x->bdiv(BigNum)               # => Inf
    $x->bdiv(Scalar)               # => Inf
    $x->bdiv(Inf)                  # => Nan

    Inf /= BigNum                  # => Inf
    Inf /= Scalar                  # => Inf
    Inf /= Inf                     # => Nan

Division of $x and $y, changing $x in-place.

eq

    $x->eq(Inf)                    # => Bool
    $x->eq(Nan)                    # => Bool
    $x->eq(BigNum)                 # => Bool

    $x == $y                       # => Bool

Equality test:

    Inf == Inf      # true
    Inf == -Inf     # false
    Inf == 0        # false
    Inf == MaN      # false

ne

    $x->ne(Inf)                    # => Bool
    $x->ne(Nan)                    # => Bool
    $x->ne(BigNum)                 # => Bool

    $x != $y                       # => Bool

Inequality test:

    Inf != Inf      # false
    Inf != -Inf     # true
    Inf != 0        # true
    Inf != MaN      # true

cmp

    $x->cmp(Inf)                   # => Scalar
    $x->cmp(BigNum)                # => Scalar
    $x->cmp(Nan)                   # => undef

    Inf <=> Any                    # => Scalar
    Any <=> Inf                    # => Scalar
    Inf <=> Nan                    # => undef

Compares $x to $y and returns a positive value when $x is greater than $y, a negative value when $x is lower than $y, or zero when $x and $y are equal.

acmp

    $x->acmp(Inf)                  # => Scalar
    $x->acmp(BigNum)               # => Scalar
    $x->acmp(Nan)                  # => undef

Compares the absolute values of $x and $y.

gt

    $x->gt(Any)                    # => Bool
    Inf > Any                      # => Bool
    Any > Inf                      # => Bool

Returns true if $x is greater than $y.

ge

    $x->ge(Any)                    # => Bool
    Inf >= Any                     # => Bool
    Any >= Inf                     # => Bool

Returns true if $x is greater or equal to $y.

lt

    $x->lt(Any)                    # => Bool
    Inf < Any                      # => Bool
    Any > Inf                      # => Bool

Returns true if $x is less than $y.

le

    $x->le(Any)                    # => Bool
    Inf <= Any                     # => Bool
    Any <= Inf                     # => Bool

Returns true if $x is less than or equal to $y.

min

    $x->min(BigNum)                # => Inf | BigNum
    $x->min(Inf)                   # => Inf

Returns $x if $x is lower than $y. Returns $y otherwise.

max

    $x->max(BigNum)                # => Inf | BigNum
    $x->max(Inf)                   # => Inf

Returns $x if $x is greater than $y. Returns $y otherwise.

atan

    $x->atan                       # => BigNum

Returns the inverse tangent of $x.

sqr

    $x->sqr                        # => Inf

Returns the result of $x**2.

sqrt / isqrt

    $x->sqrt           => Inf

Square root of $x.

bsqrt / bisqrt

Square root of $x, changing $x in-place.

pow / ipow

    $x->pow(BigNum)                # => Inf | BigNum
    $x->pow(Scalar)                # => Inf | BigNum
    $x->pow(Inf)                   # => Inf | BigNum

    Scalar ** Inf                  # => Inf | BigNum(0)
    Inf ** BigNum                  # => Inf | BigNum
    Inf ** Scalar                  # => Inf | BigNum

Raises $x to the power $y.

bpow / bipow

    $x->bpow(BigNum)               # => Inf | BigNum
    $x->bpow(Scalar)               # => Inf | BigNum
    $x->bpow(Inf)                  # => Inf | BigNum

    Inf **= BigNum                 # => Inf | BigNum
    Inf **= Scalar                 # => Inf | BigNum

Same pow(), except that it changes $x in-place.

root / iroot

    $x->root(BigNum)               # => BigNum | Inf | Nan
    $x->root(Scalar)               # => BigNum | Inf | Nan

Nth root of $x. Same as $x ** (1/$y).

broot / biroot

    $x->broot(BigNum)              # => BigNum | Inf | Nan
    $x->broot(Scalar)              # => BigNum | Inf | Nan

Nth root of $x, changing $x in-place.

binomial

    $x->binomial(BigNum)           # => BigNum | Inf
    $x->binomial(Scalar)           # => BigNum | Inf
    $x->binomial(Inf)              # => BigNum | Inf

Binomial coefficient of $x and $y.

exp

    $x->exp                        # => BigNum | Inf

Returns the following values:

    exp(+Inf) = Inf
    exp(-Inf) = 0

bexp

    $x->bexp                       # => BigNum | Inf

Same as exp(), except that it changes $x in-place.

inv

    $x->inv                        # => BigNum

Inverse value of +/-Infinity. Always returns zero.

mod / imod

    $x->mod(BigNum)                # => Nan
    $x->mod(Inf)                   # => Nan

    Scalar % Inf                   # => BigNum | Inf

Returns the remained of $x divided by $y.

bmod / bimod

    $x->bmod(Any)                  # => NaN

Sets $x to the reminder of $x divided by <$y>, which is always Nan.

lsft

    $x->lsft(BigNum)               # => Inf
    $x->lsft(Scalar)               # => Inf
    $x->lsft(Inf)                  # => Inf | Nan

    Inf << BigNum                  # => Inf
    Inf << Scalar                  # => Inf
    Inf << Inf                     # => Inf | Nan

Left-shift operation. ($x * (2 ** $y))

blsft

    $x->blsft(BigNum)              # => Inf
    $x->blsft(Scalar)              # => Inf
    $x->blsft(Inf)                 # => Inf | Nan

    Inf <<= BigNum                 # => Inf
    Inf <<= Scalar                 # => Inf
    Inf <<= Inf                    # => Inf | Nan

Left-shift operation, changing $x in-place. ($x * (2 ** $y))

rsft

    $x->rsft(BigNum)               # => Inf
    $x->rsft(Scalar)               # => Inf

    Inf >> BigNum                  # => Inf
    Inf >> Scalar                  # => Inf
    Inf >> BigNum                  # => Inf

Right-shift operation. ($x / (2 ** $y))

brsft

    $x->brsft(BigNum)              # => Inf
    $x->brsft(Scalar)              # => Inf

    Inf >>= BigNum                 # => Inf
    Inf >>= Scalar                 # => Inf

Integer right-shift operation. ($x / (2 ** $y))