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