目录

Scalar::Util::Numeric

Build Status CPAN Version

NAME

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

SYNOPSIS

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

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

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

DESCRIPTION

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.

TAGS

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

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

EXPORTS

isnum

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)

isint

isuv

isbig

isfloat

isneg

isinf

isnan

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.

uvmax

Returns UV_MAX, the largest UV (unsigned integer value).

VERSION

0.40

SEE ALSO

AUTHORS

COPYRIGHT AND LICENSE

Copyright © 2003-2020 by chocolateboy.

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.

关于

Perl模块,用于检查标量值的数值类型和属性

153.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号