#
# Here are some operations on rational numbers, represented as
# (numerator,denominator) of types integer and natural,
# respectively. The compiler recognizes rationals in this form as type
# q, making them printable with %qP, among other things.
#
# Copyright (C) 2007-2009 Dennis Furey
#
# abs                                           (38)
# difference                                  (3339)
# inverse                                      (140)
# negation                                      (54)
# power                                       (6091)
# product                                     (2520)
# quotient                                    (2657)
# rleq                                         (645)
# simplified                                  (2081)
# sum                                         (3276)
# engineering                                (10353)
# fixed                                       (2892)
# scientific                                  (6756)
#
# compressed with granularity 67
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#
{kwkZpgiwuKH{evdw{IwKD_EFRg[ptGgFoFsf]nXpajgKxyVKdkKjoO{D[nZf\v[hjr`sn{_dqJ{Ecv
gfvgixl]Lwdih_DHSdWgyJrgZDF^jN<vNB[fjgG<xqXoZ\?OFEfH[hodnVvjGioZe>iv=]znKocEvyg
wgGsgn_x\mZnkLvJkzwPEZyKngZhnkHDEJnKhyCioyVnLezjonng[vqGKjozgINg=ddvxn<dw\SgxKA
LwGoZhF_SIgd[hopvVdkhnfmnB[eXonjoxjh{gfgAaF<^Oh_npklD{Tfh\NHAwqdfXzfdnQgz{gtdgU
Faz_QBBxDkHpiZpJ[eqngWKN>xr>gSEivkNzp^`^ZeOHgDoFdab^f<=JnGeoxGqHnKoO_f^ivkPho`_
D[FRVhvFgb<>v{hwxdPdo^fpjB`bYHfyvo^kMhNEAgoDE<gs\^ldSgOKuIG?Eh\lx_ITvxhsfHbf@\D
uGmf^ZC@Jfcy\_oyDhhnf]RhYongOFsfoGFt>gh\j<<Itp@vEJkHom<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