GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Scalar::Util::Numeric(3) User Contributed Perl Documentation Scalar::Util::Numeric(3)

Scalar::Util::Numeric - numeric tests for perl scalars

    use Scalar::Util::Numeric qw(isnum isint isfloat);

    foo($bar / 2) if (isnum $bar);

    if (isint $baz) {
        # ...
    } elsif (isfloat $baz) {
        # ...
    }

This module exports a number of wrappers around perl's builtin "grok_number" function, which returns the numeric type of its argument, or 0 if it isn't numeric.

All of the functions exported by Scalar::Util::Numeric can be imported by using the ":all" tag:

    use Scalar::Util::Numeric qw(:all);

    isnum ($val)

Returns a nonzero value (indicating the numeric type) if $val is a number.

The numeric type is a conjunction of the following flags:

    0x01  IS_NUMBER_IN_UV               (number within UV range - not necessarily an integer)
    0x02  IS_NUMBER_GREATER_THAN_UV_MAX (number is greater than UV_MAX)
    0x04  IS_NUMBER_NOT_INT             (saw . or E notation)
    0x08  IS_NUMBER_NEG                 (leading minus sign)
    0x10  IS_NUMBER_INFINITY            (Infinity)
    0x20  IS_NUMBER_NAN                 (NaN - not a number)

The following flavours of "isnum" (corresponding to the flags above) are also available:

    isint
    isuv
    isbig
    isfloat
    isneg
    isinf
    isnan

"isint" returns -1 if its operand is a negative integer, 1 if it's 0 or a positive integer, and 0 otherwise.

The others always return 1 or 0.

  • "type" in autobox
  • Data::Types
  • Params::Classify
  • Params::Util
  • Scalar::Util
  • String::Numeric

0.40

  • chocolateboy <chocolate@cpan.org>
  • Michael G. Schwern <schwern@pobox.com>

Copyright (c) 2005-2014, chocolateboy.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.

2014-10-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.