File: die_on_overflow.pm

package info (click to toggle)
libmath-int64-perl 0.57-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 588 kB
  • sloc: perl: 2,593; ansic: 320; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package Math::Int64::die_on_overflow;

use strict;
use warnings;

use Math::Int64 ();

sub import {
    require Math::Int64;
    Math::Int64::_set_may_die_on_overflow(1);
    $^H{'Math::Int64::die_on_overflow'} = 1;
    goto &Math::Int64::_check_pragma_compatibility;
}


sub unimport {
    undef $^H{'Math::Int64::die_on_overflow'}
}

1;

# ABSTRACT: catch overflows when using Math::Int64

__END__

=encoding UTF-8

=head1 NAME

Math::Int64::die_on_overflow - catch overflows when using Math::Int64

=head1 SYNOPSIS

  use Math::Int64 qw(uint64);
  use Math::Int64::die_on_overflow;

  my $number = uint64(2**32);
  say($number * $number); # overflow error!


=head1 SEE ALSO

L<Math::Int64>.

=cut