#
# This module defines operations on signed integers represented in
# binary converted decimal, type %bnLX, with a boolean for the sign
# which is true if it's negative, and the digits in order of increasing
# significance.
#
# Copyright (C) 2010 Dennis Furey
#
# abs                                            (7)
# bleq                                         (711)
# brange                                      (1377)
# choose                                     (21056)
# difference                                  (4196)
# division                                    (3330)
# factorial                                  (17822)
# fromint                                      (960)
# gcd                                         (3382)
# negation                                      (15)
# odd                                           (20)
# power                                      (22226)
# predecessor                                  (536)
# product                                    (18416)
# quotient                                    (3323)
# remainder                                   (3323)
# sgn                                           (18)
# successor                                    (542)
# sum                                         (4172)
# tenfold                                       (19)
# toint                                        (379)
#
# compressed with granularity 66
#
#
# 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
#
{iwKwEkwhGiwgIsKvwoJGGivpgG[J{jsimJf{gz]ZxwZ`fx]XsN{Fez_IHsjxjfu?FkHNp@wwGFsiPn
xIZl?KjdkznGGioZuBHt^sF_SIn<dSj_gggXsihdxhHngAaG>`vDvggxvniwRDiNH<dgUFh{hz^ve[K
oggZiLcFhzp^l^AvKZHvF[_Ssnfjsdt^wDoJNFJ[feQD{J=Zty>jeFp{zpgn^pW@n<AngoFy>B[ehqG
xrHkGoZhkEh]D>^Zd^f_wDlSHrfeXoJjyFvgZ]HcFFidV_roPfJZnZzkR^neRv^sHwZoPpd@<Nx`hyJ
\<N_z?HcSFqjFSVZnKJ{h\dGFnDdxiFhx{DgDj_PwhxpkP^yKIIvDF^`?QBBgO_oHOJ{Fpfn{N>jvfv
kOOivgFEOHf`{Hg`iH{^GRn>jtGxVFSVvjkJ{fffRVd`{FqbJ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