1# GMP mpq module.
2
3# Copyright 2001 Free Software Foundation, Inc.
4#
5#  This file is part of the GNU MP Library.
6#
7#  The GNU MP Library is free software; you can redistribute it and/or modify
8#  it under the terms of either:
9#
10#    * the GNU Lesser General Public License as published by the Free
11#      Software Foundation; either version 3 of the License, or (at your
12#      option) any later version.
13#
14#  or
15#
16#    * the GNU General Public License as published by the Free Software
17#      Foundation; either version 2 of the License, or (at your option) any
18#      later version.
19#
20#  or both in parallel, as here.
21#
22#  The GNU MP Library is distributed in the hope that it will be useful, but
23#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25#  for more details.
26#
27#  You should have received copies of the GNU General Public License and the
28#  GNU Lesser General Public License along with the GNU MP Library.  If not,
29#  see https://www.gnu.org/licenses/.
30
31
32package GMP::Mpq;
33
34require GMP;
35require Exporter;
36@ISA = qw(GMP Exporter);
37@EXPORT = qw();
38@EXPORT_OK = qw();
39%EXPORT_TAGS = ('all' => [qw(canonicalize den inv mpq num)],
40		'constants'   => [@EXPORT],
41		'noconstants' => [@EXPORT] );
42Exporter::export_ok_tags('all');
43
44use overload
45    '+'   => \&overload_add,     '+='  => \&overload_addeq,
46    '-'   => \&overload_sub,     '-='  => \&overload_subeq,
47    '*'   => \&overload_mul,     '*='  => \&overload_muleq,
48    '/'   => \&overload_div,     '/='  => \&overload_diveq,
49    '**'  => \&overload_pow,     '**=' => \&overload_poweq,
50    '<<'  => \&overload_lshift,  '<<=' => \&overload_lshifteq,
51    '>>'  => \&overload_rshift,  '>>=' => \&overload_rshifteq,
52
53    'bool' => \&overload_bool,
54    'not'  => \&overload_not,
55    '!'    => \&overload_not,
56    '=='   => \&overload_eq,
57    '!='   => \&overload_ne,
58    '<=>'  => \&overload_spaceship,
59    '++'   => \&overload_inc,
60    '--'   => \&overload_dec,
61    'abs'  => \&overload_abs,
62    'neg'  => \&overload_neg,
63    '='    => \&overload_copy,
64    '""'   => \&overload_string;
65
66my $constants = { };
67
68sub import {
69  foreach (@_) {
70    if ($_ eq ':constants') {
71      overload::constant ('integer' => \&overload_constant,
72			  'binary'  => \&overload_constant,
73			  'float'   => \&overload_constant);
74    } elsif ($_ eq ':noconstants') {
75      overload::remove_constant ('integer' => \&overload_constant,
76				 'binary'  => \&overload_constant,
77				 'float'   => \&overload_constant);
78    }
79  }
80  goto &Exporter::import;
81}
82
831;
84__END__
85
86
87# Local variables:
88# perl-indent-level: 2
89# End:
90