perl

 view release on metacpan or  search on metacpan

Configure  view on Meta::CPAN

#define DOUBLESIZE $doublesize
#$d_longdbl HAS_LONG_DOUBLE
#ifdef HAS_LONG_DOUBLE
#define LONG_DOUBLESIZE $longdblsize
#define LONG_DOUBLEKIND $longdblkind
#endif
#include <math.h>
#include <string.h>
#include <stdio.h>
/* Note that whether the sign bit is on or off
 * for NaN depends on the CPU/FPU, and possibly
 * can be affected by the build toolchain.
 *
 * For example for older MIPS and HP-PA 2.0 the quiet NaN is:
 * 0x7f, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
 * 0x7f, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 * (respectively) as opposed to the more usual
 * 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 *
 * Pre-IEEE-754 floating point format do not even have inf/nan support
 * at all.  They might have a "max" value (DBL_MAX), which may be deadly
 * to even mention, causing immediate SIGFPE or equivalent: this is
 * the case with VAX floating point, for example.
 */

MANIFEST  view on Meta::CPAN

cpan/bignum/t/bignum.t			See if bignum works
cpan/bignum/t/bigrat.t			See if bigrat works
cpan/bignum/t/bii_e_pi.t		See if bigint exports e() and PI()
cpan/bignum/t/biinfnan.t		See if bignum works
cpan/bignum/t/bir_e_pi.t		See if bigrat exports e() and PI()
cpan/bignum/t/bn_lite.t			See if bignum with Math::BigInt::Lite works
cpan/bignum/t/bninfnan.t		See if bignum works
cpan/bignum/t/br_lite.t			See if bigrat with Math::BigInt::Lite works
cpan/bignum/t/brinfnan.t		See if bignum works
cpan/bignum/t/in_effect.t		See if in_effect() works
cpan/bignum/t/infnan.inc		See if bignum with inf/NaN works
cpan/bignum/t/option_a.t		See if bignum a => X works
cpan/bignum/t/option_l.t		See if bignum l => X works
cpan/bignum/t/option_p.t		See if bignum p => X works
cpan/bignum/t/overrides.t		See if global overrides behave
cpan/bignum/t/ratopt_a.t		See if bigrat a => X works
cpan/bignum/t/scope_f.t			See if no bignum works
cpan/bignum/t/scope_i.t			See if no bigint works
cpan/bignum/t/scope_r.t			See if no bigrat works
cpan/Compress-Raw-Bzip2/Bzip2.xs
cpan/Compress-Raw-Bzip2/bzip2-src/blocksort.c

Porting/Glossary  view on Meta::CPAN

	This variable conditionally defines HAS_MUNMAP if munmap() is
	available to unmap a region mapped by mmap().

d_mymalloc (mallocsrc.U):
	This variable conditionally defines MYMALLOC in case other parts
	of the source want to take special action if MYMALLOC is used.
	This may include different sorts of profiling or error detection.

d_nan (d_nan.U):
	This variable conditionally defines HAS_NAN if nan() is
	available to generate NaN.

d_nanosleep (d_nanosleep.U):
	This variable conditionally defines HAS_NANOSLEEP
	if nanosleep() is available to sleep with 1E-9 sec accuracy.

d_ndbm (i_ndbm.U):
	This variable conditionally defines the HAS_NDBM symbol, which
	indicates that both the ndbm.h include file and an appropriate ndbm
	library exist.  Consult the different i_*ndbm variables
	to find out the actual include location.  Sometimes, a system has the

Porting/config_H  view on Meta::CPAN

 *	The returned values are defined in <float.h> and are:
 *
 *	FP_PLUS_NORM	Positive normalized, nonzero
 *	FP_MINUS_NORM	Negative normalized, nonzero
 *	FP_PLUS_DENORM	Positive denormalized, nonzero
 *	FP_MINUS_DENORM	Negative denormalized, nonzero
 *	FP_PLUS_ZERO	+0.0
 *	FP_MINUS_ZERO	-0.0
 *	FP_PLUS_INF	+INF
 *	FP_MINUS_INF	-INF
 *	FP_NANS		Signaling Not a Number (NaNS)
 *	FP_NANQ		Quiet Not a Number (NaNQ)
 */
/*#define HAS_CLASS		/ **/

/* HAS_CLEARENV:
 *	This symbol, if defined, indicates that the clearenv () routine is
 *	available for use.
 */
#define HAS_CLEARENV		/**/

/* HAS_STRUCT_CMSGHDR:

README.vms  view on Meta::CPAN

C compiler, namely representing doubles with D_FLOAT on VAX and G_FLOAT on
Alpha.  Single precision floating point values are represented in F_FLOAT
format when either D_FLOAT or G_FLOAT is in use for doubles.  Beginning with
5.8.0, Alpha builds now use IEEE floating point formats by default, which in
VMS parlance are S_FLOAT for singles and T_FLOAT for doubles.  IEEE is not
available on VAX, so F_FLOAT and D_FLOAT remain the defaults for singles and
doubles respectively.  Itanium builds have always used IEEE by default. The 
available non-default options are G_FLOAT on VAX and D_FLOAT or G_FLOAT on 
Alpha or Itanium.

The use of IEEE on Alpha or Itanium introduces NaN, infinity, and denormalization
capabilities not available with D_FLOAT and G_FLOAT.  When using one of those
non-IEEE formats, silent underflow and overflow are emulated in the conversion
of strings to numbers, but it is preferable to get the real thing by using
IEEE where possible.

Regardless of what floating point format you consider preferable, be aware
that the choice may have an impact on compatibility with external libraries,
such as database interfaces, and with existing data, such as data created with
the C<pack> function and written to disk, or data stored via the Storable
extension.  For example, a C<pack("d", $foo)")> will create a D_FLOAT,

charclass_invlists.h  view on Meta::CPAN

	"600000",
	"700000",
	"800000",
	"900000",
	"1000000",
	"10000000",
	"20000000",
	"100000000",
	"10000000000",
	"1000000000000",
	"NaN",
	"nan",
	NULL
};

static const char * const UNI_sb_values[] = {
	"AT",
	"at",
	"ATerm",
	"aterm",
	"CL",

config_h.SH  view on Meta::CPAN

 *	The returned values are defined in <float.h> and are:
 *
 *	FP_PLUS_NORM	Positive normalized, nonzero
 *	FP_MINUS_NORM	Negative normalized, nonzero
 *	FP_PLUS_DENORM	Positive denormalized, nonzero
 *	FP_MINUS_DENORM	Negative denormalized, nonzero
 *	FP_PLUS_ZERO	+0.0
 *	FP_MINUS_ZERO	-0.0
 *	FP_PLUS_INF	+INF
 *	FP_MINUS_INF	-INF
 *	FP_NANS		Signaling Not a Number (NaNS)
 *	FP_NANQ		Quiet Not a Number (NaNQ)
 */
#$d_class HAS_CLASS		/**/

/* HAS_CLEARENV:
 *	This symbol, if defined, indicates that the clearenv () routine is
 *	available for use.
 */
#$d_clearenv HAS_CLEARENV		/**/

/* HAS_STRUCT_CMSGHDR:

cpan/JSON-PP/lib/JSON/PP.pm  view on Meta::CPAN

results in a different JSON text from the one JSON::XS encodes (and
thus may break tests that compare entire JSON texts). If you do
need the previous behavior for compatibility or for finer control,
set PERL_JSON_PP_USE_B environmental variable to true before you
C<use> JSON::PP (or JSON.pm).

Note that numerical precision has the same meaning as under Perl (so
binary to decimal conversion follows the same rules as in Perl, which
can differ to other languages). Also, your perl interpreter might expose
extensions to the floating point numbers of your platform, such as
infinities or NaN's - these cannot be represented in JSON, and it is an
error to pass those in.

JSON::PP (and JSON::XS) trusts what you pass to C<encode> method
(or C<encode_json> function) is a clean, validated data structure with
values that can be represented as valid JSON values only, because it's
not from an external data source (as opposed to JSON texts you pass to
C<decode> or C<decode_json>, which JSON::PP considers tainted and
doesn't trust). As JSON::PP doesn't know exactly what you and consumers
of your JSON texts want the unexpected values to be (you may want to
convert them into null, or to stringify them with or without
normalisation (string representation of infinities/NaN may vary
depending on platforms), or to croak without conversion), you're advised
to do what you and your consumers need before you encode, and also not
to numify values that may start with values that look like a number
(including infinities/NaN), without validating.

=back

=head2 OBJECT SERIALISATION

As JSON cannot directly represent Perl objects, you have to choose between
a pure JSON representation (without the ability to deserialise the object
automatically again), and a nonstandard extension to the JSON syntax,
tagged values.

cpan/Math-BigInt-FastCalc/t/biglog.t  view on Meta::CPAN


is($class->new(21)->blog(undef, 71),
   '3.0445224377234229965005979803657054342845752874046106401940844835750742',
   "$class->new(21)->blog(undef, 71)");

###############################################################################

# These tests are now really fast, since they collapse to blog(10), basically
# Don't attempt to run them with older versions. You are warned.

# $x < 0 => NaN
is($class->new(-2)->blog(),    'NaN', "$class->new(-2)->blog()");
is($class->new(-1)->blog(),    'NaN', "$class->new(-1)->blog()");
is($class->new(-10)->blog(),   'NaN', "$class->new(-10)->blog()");
is($class->new(-2, 2)->blog(), 'NaN', "$class->new(-2, 2)->blog()");

my $ten = $class->new(10)->blog();

# 10 is cached (up to 75 digits)
is($class->new(10)->blog(),
   '2.302585092994045684017991454684364207601',
   qq|$class->new(10)->blog()|);

# 0.1 is using the cached value for log(10), too

cpan/Math-BigInt/lib/Math/BigFloat.pm  view on Meta::CPAN

package Math::BigFloat;

#
# Mike grinned. 'Two down, infinity to go' - Mike Nostrus in 'Before and After'
#

# The following hash values are used internally:
# sign  : "+", "-", "+inf", "-inf", or "NaN" if not a number
#   _m  : mantissa ($LIB thingy)
#   _es : sign of _e
#   _e  : exponent ($LIB thingy)
#   _a  : accuracy
#   _p  : precision

use 5.006001;
use strict;
use warnings;

cpan/Math-BigInt/t/Math/BigInt/Scalar.pm  view on Meta::CPAN

require Exporter;

our @ISA = qw(Exporter);

our $VERSION = '0.13';

##############################################################################
# global constants, flags and accessory

# constants for easier life
my $nan = 'NaN';

##############################################################################
# create objects from various representations

sub _new {
    # create scalar ref from string
    my $d = $_[1];
    my $x = $d;                 # make copy
    \$x;
}

cpan/Math-BigInt/t/bdigitsum-mbi.t  view on Meta::CPAN

isa_ok($y, 'Math::BigInt');
is($x, "6");
is($y, "6");

# Infinity

$x = Math::BigInt -> binf("+");
isa_ok($x, 'Math::BigInt');
$y = $x -> bdigitsum();
isa_ok($y, 'Math::BigInt');
is($x, "NaN");
is($y, "NaN");

$x = Math::BigInt -> binf("-");
isa_ok($x, 'Math::BigInt');
$y = $x -> bdigitsum();
isa_ok($y, 'Math::BigInt');
is($x, "NaN");
is($y, "NaN");

# NaN

$x = Math::BigInt -> bnan();
isa_ok($x, 'Math::BigInt');
$y = $x -> bdigitsum();
isa_ok($y, 'Math::BigInt');
is($x, "NaN");
is($y, "NaN");

###############################################################################
# digitsum()

# Finite numbers.

$x = Math::BigInt -> new("123");
isa_ok($x, 'Math::BigInt');
$y = $x -> digitsum();
isa_ok($y, 'Math::BigInt');

cpan/Math-BigInt/t/bdstr-mbi.t  view on Meta::CPAN


    note "\n$test\n\n";
    eval $test;

    is($str, $expected, qq|input value is "$x_str"|);
    is($x,   $x_str, "input object is unmodified");
}

__DATA__

NaN:NaN

inf:inf
-inf:-inf

0:0

# positive numbers

1:1
10:10

cpan/Math-BigInt/t/bestr-mbf.t  view on Meta::CPAN


    note "\n$test\n\n";
    eval $test;

    is($str, $expected, qq|input value is "$x_str"|);
    is($x,   $x_str, "input object is unmodified");
}

__DATA__

NaN:NaN

inf:inf
-inf:-inf

0:0e+0

# positive numbers

0.000000000001:1e-12
0.00000000001:10e-12

cpan/Math-BigInt/t/bestr-mbi.t  view on Meta::CPAN


    note "\n$test\n\n";
    eval $test;

    is($str, $expected, qq|input value is "$x_str"|);
    is($x,   $x_str, "input object is unmodified");
}

__DATA__

NaN:NaN

inf:inf
-inf:-inf

0:0e+0

# positive numbers

1:1e+0
10:10e+0

cpan/Math-BigInt/t/bfib-mbi.t  view on Meta::CPAN

is($y, "610", "bfib(15)");

$x = Math::BigInt -> new("20");
$y = $x -> bfib();
is($y, "6765", "bfib(20)");

$x = Math::BigInt -> new("250");
$y = $x -> bfib();
is($y, "7896325826131730509282738943634332893686268675876375", "bfib(250)");

# Infinites and NaN.

$x = Math::BigInt -> binf("+");
$y = $x -> bfib();
is($y, "inf", "bfib(+inf)");

$x = Math::BigInt -> binf("-");
$y = $x -> bfib();
is($y, "NaN", "bfib(-inf)");

$x = Math::BigInt -> bnan();
$y = $x -> bfib();
is($y, "NaN", "bfib(NaN)");

###############################################################################
# List context.
###############################################################################

my @y;

$x = Math::BigInt -> new("10");
@y = $x -> bfib();
is_deeply(\@y, [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55], "bfib(10)");

cpan/Math-BigInt/t/bigfltpm.inc  view on Meta::CPAN

is($x->{_a}, undef, qq|\$x = $CLASS->new(2); \$x->bnan(); \$x->{_a}|);
is($x->{_p}, undef, qq|\$x = $CLASS->new(2); \$x->bnan(); \$x->{_p}|);

###############################################################################
# bone/binf etc as plain calls (Lite failed them)

is($CLASS->bzero(),      0,      qq|$CLASS->bzero()|);
is($CLASS->bone(),       1,      qq|$CLASS->bone()|);
is($CLASS->bone("+"),    1,      qq|$CLASS->bone("+")|);
is($CLASS->bone("-"),    -1,     qq|$CLASS->bone("-")|);
is($CLASS->bnan(),       "NaN",  qq|$CLASS->bnan()|);
is($CLASS->binf(),       "inf",  qq|$CLASS->binf()|);
is($CLASS->binf("+"),    "inf",  qq|$CLASS->binf("+")|);
is($CLASS->binf("-"),    "-inf", qq|$CLASS->binf("-")|);
is($CLASS->binf("-inf"), "-inf", qq|$CLASS->binf("-inf")|);

$CLASS->accuracy(undef);        # reset
$CLASS->precision(undef);       # reset

###############################################################################
# bsqrt() with set global A/P or A/P enabled on $x, also a test whether bsqrt()

cpan/Math-BigInt/t/biglog.t  view on Meta::CPAN


is($class->new(21)->blog(undef, 71),
   '3.0445224377234229965005979803657054342845752874046106401940844835750742',
   "$class->new(21)->blog(undef, 71)");

###############################################################################

# These tests are now really fast, since they collapse to blog(10), basically
# Don't attempt to run them with older versions. You are warned.

# $x < 0 => NaN
is($class->new(-2)->blog(),    'NaN', "$class->new(-2)->blog()");
is($class->new(-1)->blog(),    'NaN', "$class->new(-1)->blog()");
is($class->new(-10)->blog(),   'NaN', "$class->new(-10)->blog()");
is($class->new(-2, 2)->blog(), 'NaN', "$class->new(-2, 2)->blog()");

my $ten = $class->new(10)->blog();

# 10 is cached (up to 75 digits)
is($class->new(10)->blog(),
   '2.302585092994045684017991454684364207601',
   qq|$class->new(10)->blog()|);

# 0.1 is using the cached value for log(10), too

cpan/Math-BigInt/t/blucas-mbi.t  view on Meta::CPAN

is($y, "1364", "blucas(15)");

$x = Math::BigInt -> new("20");
$y = $x -> blucas();
is($y, "15127", "blucas(20)");

$x = Math::BigInt -> new("250");
$y = $x -> blucas();
is($y, "17656721319717734662791328845675730903632844218828123", "blucas(250)");

# Infinites and NaN.

$x = Math::BigInt -> binf("+");
$y = $x -> blucas();
is($y, "inf", "blucas(+inf)");

$x = Math::BigInt -> binf("-");
$y = $x -> blucas();
is($y, "NaN", "blucas(-inf)");

$x = Math::BigInt -> bnan();
$y = $x -> blucas();
is($y, "NaN", "blucas(NaN)");

###############################################################################
# List context.
###############################################################################

my @y;

$x = Math::BigInt -> new("10");
@y = $x -> blucas();
is_deeply(\@y, [2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123], "blucas(10)");

cpan/Math-BigInt/t/bnok-mbf.t  view on Meta::CPAN

                      is($k -> bstr(), $kval,
                         "'$test' second input arg is unmodified");
                  }
              };
        }
    }
}

__DATA__

# n and/or k is NaN

NaN:NaN:NaN
NaN:0:NaN
NaN:3:NaN
3:NaN:NaN
NaN:-3:NaN
-3:NaN:NaN

# n = inf

inf:-inf:NaN
inf:-3:0
inf:-2:0
inf:-1:0
inf:0:1
inf:1:inf
inf:2:inf
inf:3:inf
inf:inf:NaN

# n = -inf

-inf:-inf:NaN
-inf:-3:0
-inf:-2:0
-inf:-1:0
-inf:0:1
-inf:1:-inf
-inf:2:inf
-inf:3:-inf
-inf:inf:NaN

# k = inf

-3:inf:NaN
-2:inf:NaN
-1:inf:NaN
0:inf:NaN
1:inf:NaN
2:inf:NaN
3:inf:NaN

# k = -inf

-3:-inf:NaN
-2:-inf:NaN
-1:-inf:NaN
0:-inf:NaN
1:-inf:NaN
2:-inf:NaN
3:-inf:NaN

# n = -15, k = n - 15 ... n + 15

-15:-30:-77558760
-15:-29:40116600
-15:-28:-20058300
-15:-27:9657700
-15:-26:-4457400
-15:-25:1961256
-15:-24:-817190

cpan/Math-BigInt/t/bnok-mbi.t  view on Meta::CPAN

                      is($k -> bstr(), $kval,
                         "'$test' second input arg is unmodified");
                  }
              };
        }
    }
}

__DATA__

# n and/or k is NaN

NaN:NaN:NaN
NaN:0:NaN
NaN:3:NaN
3:NaN:NaN
NaN:-3:NaN
-3:NaN:NaN

# n = inf

inf:-inf:NaN
inf:-3:0
inf:-2:0
inf:-1:0
inf:0:1
inf:1:inf
inf:2:inf
inf:3:inf
inf:inf:NaN

# n = -inf

-inf:-inf:NaN
-inf:-3:0
-inf:-2:0
-inf:-1:0
-inf:0:1
-inf:1:-inf
-inf:2:inf
-inf:3:-inf
-inf:inf:NaN

# k = inf

-3:inf:NaN
-2:inf:NaN
-1:inf:NaN
0:inf:NaN
1:inf:NaN
2:inf:NaN
3:inf:NaN

# k = -inf

-3:-inf:NaN
-2:-inf:NaN
-1:-inf:NaN
0:-inf:NaN
1:-inf:NaN
2:-inf:NaN
3:-inf:NaN

# n = -15, k = n - 15 ... n + 15

-15:-30:-77558760
-15:-29:40116600
-15:-28:-20058300
-15:-27:9657700
-15:-26:-4457400
-15:-25:1961256
-15:-24:-817190

cpan/Math-BigInt/t/bnstr-mbf.t  view on Meta::CPAN

        eval $test;

        is($str, $expected, qq|input value is "$x_str"|);
        is($x,   $x_str, "input object is unmodified");
    }

}

__DATA__

NaN:NaN

inf:inf
-inf:-inf

0:0e+0

# positive numbers

0.000000000001:1e-12
0.00000000001:1e-11

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.634 second using v1.00-cache-1.14-grep-28634ff-cpan-b2b8777cff0 )