File: die_on_overflow.pm

package info (click to toggle)
libmath-int128-perl 0.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 604 kB
  • sloc: perl: 2,614; ansic: 340; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 921 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
46
47
48
49
50
package Math::Int128::die_on_overflow;

use strict;
use warnings;

our $VERSION = '0.22';

sub import {
    require Math::Int128;
    Math::Int128::_set_may_die_on_overflow(1);
    $^H{'Math::Int128::die_on_overflow'} = 1
}


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

1;

__END__

=encoding UTF-8

=head1 NAME

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

=head1 SYNOPSIS

  use Math::Int128 qw(uint128);
  use Math::Int128::die_on_overflow;

  my $number = uint128(2**64);
  say($number * $number); # overflow error!


=head1 SEE ALSO

L<Math::Int128>.

=head1 COPYRIGHT AND LICENSE

Copyright E<copy> 2011, 2013 by Salvador FandiƱo (sfandino@yahoo.com)

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.

=cut