From ba237a9d91f0a77dc0dd562cb60d073ca8dcf0e0 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 26 Feb 2002 12:19:02 +0000 Subject: [PATCH] Patch level : no patch Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll) git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- gfm/adate360.c | 76 + gfm/adate365.c | 144 ++ gfm/adatenly.c | 109 ++ gfm/addarr.c | 64 + gfm/addarrd.c | 82 ++ gfm/adddfd.c | 57 + gfm/addid.c | 47 + gfm/addld.c | 51 + gfm/addstr.c | 69 + gfm/adduid.c | 46 + gfm/adduld.c | 50 + gfm/advpmt.c | 55 + gfm/agmn.asm | 111 ++ gfm/agmn.c | 72 + gfm/amort.c | 100 ++ gfm/amorttbl.c | 112 ++ gfm/atod.c | 245 ++++ gfm/atodr.c | 252 ++++ gfm/bondprc.c | 131 ++ gfm/bondyld.c | 122 ++ gfm/build | 5 + gfm/build3 | 6 + gfm/buildd3 | 6 + gfm/builddos | 5 + gfm/buildsh | 1 + gfm/comp.c | 51 + gfm/compaux.c | 384 +++++ gfm/compcomp.c | 52 + gfm/compsimp.c | 52 + gfm/d10by5.c | 53 + gfm/d10by5t.c | 53 + gfm/dabs.c | 47 + gfm/dacos.c | 80 ++ gfm/dadd.c | 127 ++ gfm/dadx.c | 110 ++ gfm/dalloc.c | 54 + gfm/dalog.c | 98 ++ gfm/daralloc.c | 81 ++ gfm/darcpy.c | 77 + gfm/darfree.c | 61 + gfm/dasin.c | 74 + gfm/datan.c | 47 + gfm/datax.c | 83 ++ gfm/dbd360.c | 59 + gfm/dbd365.c | 143 ++ gfm/dbdnly.c | 74 + gfm/dchgs.c | 47 + gfm/dchix.c | 61 + gfm/dcmp.c | 76 + gfm/dcos.c | 46 + gfm/dcoss.c | 56 + gfm/dcot.c | 97 ++ gfm/dcox.c | 67 + gfm/dcpy.c | 49 + gfm/dctod.c | 63 + gfm/ddeg.c | 46 + gfm/ddiv.c | 60 + gfm/ddivpf.c | 149 ++ gfm/ddivpr.c | 86 ++ gfm/ddivpt.c | 86 ++ gfm/ddivr.c | 75 + gfm/ddivt.c | 74 + gfm/ddix.c | 151 ++ gfm/ddixf.c | 57 + gfm/ddixr.c | 63 + gfm/ddixt.c | 67 + gfm/deltrz.c | 55 + gfm/demo01.c | 26 + gfm/demo02.c | 22 + gfm/demo03.c | 18 + gfm/demo04.c | 23 + gfm/demo05.c | 24 + gfm/demo06.c | 43 + gfm/demo07.c | 56 + gfm/demo08.c | 36 + gfm/demo09.c | 26 + gfm/demo10.c | 11 + gfm/demo11.c | 16 + gfm/demo12.c | 44 + gfm/demo13.c | 34 + gfm/demo14.c | 18 + gfm/demo15.c | 39 + gfm/demo16.c | 65 + gfm/demo17.c | 44 + gfm/demo18.c | 53 + gfm/demo19.c | 46 + gfm/dexp.c | 77 + gfm/dexx.c | 113 ++ gfm/dfact.c | 61 + gfm/dfprintf.c | 71 + gfm/dfract.c | 45 + gfm/dfree.c | 54 + gfm/dfscanf.c | 64 + gfm/dftod.c | 129 ++ gfm/dftodr.c | 123 ++ gfm/dint.c | 44 + gfm/diseq.c | 53 + gfm/disge.c | 52 + gfm/disgt.c | 52 + gfm/disint.c | 47 + gfm/disle.c | 54 + gfm/dislt.c | 54 + gfm/disne.c | 54 + gfm/disneg.c | 44 + gfm/dispos.c | 44 + gfm/diszero.c | 44 + gfm/divarr.c | 66 + gfm/divarrd.c | 90 ++ gfm/divdfd.c | 58 + gfm/divid.c | 51 + gfm/divld.c | 60 + gfm/divstr.c | 68 + gfm/divuid.c | 51 + gfm/divuld.c | 54 + gfm/dllgfm.c | 13 + gfm/dllgfm.def | 52 + gfm/dllgfm.mak | 3472 ++++++++++++++++++++++++++++++++++++++++++++++ gfm/dln.c | 65 + gfm/dlnx.c | 100 ++ gfm/dlog.c | 66 + gfm/dmag.c | 59 + gfm/dmant.c | 69 + gfm/dmax.c | 53 + gfm/dmby1.asm | 101 ++ gfm/dmby1.c | 51 + gfm/dmby1r.asm | 112 ++ gfm/dmby1r.c | 56 + gfm/dmbyn.asm | 326 +++++ gfm/dmbyn.c | 128 ++ gfm/dmbyp10.asm | 190 +++ gfm/dmbyp10.c | 50 + gfm/dmbyp10t.asm | 134 ++ gfm/dmbyp10t.c | 53 + gfm/dmbyp10tc.c | 53 + gfm/dmean.c | 77 + gfm/dmi.asm | 74 + gfm/dmi.c | 72 + gfm/dmin.c | 53 + gfm/dmod.c | 69 + gfm/dmoddf.c | 54 + gfm/dmodi.c | 45 + gfm/dmodl.c | 48 + gfm/dmodui.c | 44 + gfm/dmodul.c | 48 + gfm/dmul.c | 129 ++ gfm/dmulr.c | 76 + gfm/dmult.c | 78 ++ gfm/dmux.c | 112 ++ gfm/dpct.c | 101 ++ gfm/dpdb.c | 121 ++ gfm/dpdbtbl.c | 123 ++ gfm/dpddb.c | 51 + gfm/dpddbtbl.c | 51 + gfm/dpow.c | 110 ++ gfm/dpowi.c | 82 ++ gfm/dpowrat.c | 123 ++ gfm/dpoxi.c | 134 ++ gfm/dprec.c | 39 + gfm/dprintf.c | 65 + gfm/dpsl.c | 106 ++ gfm/dpsltbl.c | 104 ++ gfm/dpsoy.c | 127 ++ gfm/dpsoytbl.c | 126 ++ gfm/drad.c | 41 + gfm/droot.c | 101 ++ gfm/drooti.c | 103 ++ gfm/dround.c | 78 ++ gfm/dscanf.c | 62 + gfm/dsetertn.c | 50 + gfm/dsign.c | 49 + gfm/dsin.c | 49 + gfm/dsins.c | 57 + gfm/dsort.c | 118 ++ gfm/dsprintf.c | 299 ++++ gfm/dsqrt.c | 53 + gfm/dsqx.c | 89 ++ gfm/dsscanf.c | 63 + gfm/dsub.c | 130 ++ gfm/dsux.c | 119 ++ gfm/dswap.c | 49 + gfm/dtan.c | 94 ++ gfm/dtoa.c | 111 ++ gfm/dtoac.c | 118 ++ gfm/dtoacr.c | 152 ++ gfm/dtoaf.c | 378 +++++ gfm/dtoar.c | 148 ++ gfm/dtodc.c | 67 + gfm/dtodf.c | 75 + gfm/dtoeng.c | 197 +++ gfm/dtofr.c | 83 ++ gfm/dtoi.c | 89 ++ gfm/dtol.c | 83 ++ gfm/dtosci.c | 186 +++ gfm/dtoui.c | 59 + gfm/dtoul.c | 58 + gfm/dtrunc.c | 79 ++ gfm/dtrux.c | 61 + gfm/dzero.c | 43 + gfm/dzeroarr.c | 62 + gfm/efftonom.c | 91 ++ gfm/errname.c | 67 + gfm/frtod.c | 67 + gfm/funname.c | 62 + gfm/gcmp.asm | 106 ++ gfm/gcmp.c | 46 + gfm/gf.h | 86 ++ gfm/gfd.h | 25 + gfm/gfmdefs.c | 8 + gfm/ginc.asm | 61 + gfm/ginc.c | 40 + gfm/gl.c | 13 + gfm/gm.equ | 45 + gfm/gm.h | 136 ++ gfm/gmec.c | 49 + gfm/gmef.c | 47 + gfm/gmfequs.h | 203 +++ gfm/gmfname.h | 208 +++ gfm/gmfncnum.h | 206 +++ gfm/gmfuncts.h | 235 ++++ gfm/gmglobal.c | 165 +++ gfm/gmrs.c | 34 + gfm/gmserri.c | 41 + gfm/gmsys1.h | 7 + gfm/gmsystem.h | 147 ++ gfm/hmi.asm | 70 + gfm/hmi.c | 50 + gfm/import.h | 12 + gfm/intraux.c | 298 ++++ gfm/irr.c | 224 +++ gfm/itod.c | 42 + gfm/libgfm.sl | 124 ++ gfm/linest.c | 145 ++ gfm/lookarr.c | 122 ++ gfm/ltod.c | 47 + gfm/makeasm | 743 ++++++++++ gfm/makefile | 513 +++++++ gfm/makefile3 | 509 +++++++ gfm/makelsh | 507 +++++++ gfm/makid.c | 44 + gfm/makld.c | 54 + gfm/makuid.c | 44 + gfm/makuld.c | 53 + gfm/maxarr.c | 77 + gfm/median.c | 92 ++ gfm/mgmn.asm | 313 +++++ gfm/mgmn.c | 85 ++ gfm/minarr.c | 74 + gfm/mirr.c | 137 ++ gfm/mli.asm | 153 ++ gfm/mli.c | 68 + gfm/model.h | 6 + gfm/mul10.asm | 149 ++ gfm/mul10.c | 104 ++ gfm/mul10ad.asm | 322 +++++ gfm/mul10ad.c | 132 ++ gfm/mul10l.asm | 189 +++ gfm/mul10l.c | 69 + gfm/mularr.c | 65 + gfm/mularrd.c | 83 ++ gfm/muldfd.c | 58 + gfm/mulid.c | 48 + gfm/mulld.c | 58 + gfm/mulstr.c | 67 + gfm/muluid.c | 48 + gfm/mululd.c | 54 + gfm/nfv.c | 83 ++ gfm/nomtoeff.c | 98 ++ gfm/npv.c | 82 ++ gfm/padd.c | 59 + gfm/pchange.c | 59 + gfm/pdiv.c | 52 + gfm/pmul.c | 51 + gfm/pof.c | 53 + gfm/predx.c | 52 + gfm/predy.c | 51 + gfm/prologue.h | 497 +++++++ gfm/psub.c | 59 + gfm/ptoy.c | 82 ++ gfm/roundcnt.c | 96 ++ gfm/scanf.c | 92 ++ gfm/scanfx.c | 344 +++++ gfm/sgmn.asm | 115 ++ gfm/sgmn.c | 77 + gfm/simp360.c | 53 + gfm/simp365.c | 53 + gfm/simpaux.c | 138 ++ gfm/smi.asm | 81 ++ gfm/smi.c | 66 + gfm/spfv.c | 73 + gfm/sppv.c | 72 + gfm/sq5to4.c | 78 ++ gfm/stnddev.c | 99 ++ gfm/subarr.c | 64 + gfm/subarrd.c | 81 ++ gfm/subdfd.c | 58 + gfm/subid.c | 48 + gfm/subld.c | 50 + gfm/substr.c | 68 + gfm/subuid.c | 48 + gfm/subuld.c | 52 + gfm/sumarr.c | 83 ++ gfm/sumarrn.c | 78 ++ gfm/sumarrp.c | 78 ++ gfm/trunccnt.c | 85 ++ gfm/uitod.c | 42 + gfm/ultod.c | 49 + gfm/usfv.c | 78 ++ gfm/uspv.c | 78 ++ gfm/wmean.c | 90 ++ gfm/ytop.c | 81 ++ 310 files changed, 31301 insertions(+) create mode 100755 gfm/adate360.c create mode 100755 gfm/adate365.c create mode 100755 gfm/adatenly.c create mode 100755 gfm/addarr.c create mode 100755 gfm/addarrd.c create mode 100755 gfm/adddfd.c create mode 100755 gfm/addid.c create mode 100755 gfm/addld.c create mode 100755 gfm/addstr.c create mode 100755 gfm/adduid.c create mode 100755 gfm/adduld.c create mode 100755 gfm/advpmt.c create mode 100755 gfm/agmn.asm create mode 100755 gfm/agmn.c create mode 100755 gfm/amort.c create mode 100755 gfm/amorttbl.c create mode 100755 gfm/atod.c create mode 100755 gfm/atodr.c create mode 100755 gfm/bondprc.c create mode 100755 gfm/bondyld.c create mode 100755 gfm/build create mode 100755 gfm/build3 create mode 100755 gfm/buildd3 create mode 100755 gfm/builddos create mode 100755 gfm/buildsh create mode 100755 gfm/comp.c create mode 100755 gfm/compaux.c create mode 100755 gfm/compcomp.c create mode 100755 gfm/compsimp.c create mode 100755 gfm/d10by5.c create mode 100755 gfm/d10by5t.c create mode 100755 gfm/dabs.c create mode 100755 gfm/dacos.c create mode 100755 gfm/dadd.c create mode 100755 gfm/dadx.c create mode 100755 gfm/dalloc.c create mode 100755 gfm/dalog.c create mode 100755 gfm/daralloc.c create mode 100755 gfm/darcpy.c create mode 100755 gfm/darfree.c create mode 100755 gfm/dasin.c create mode 100755 gfm/datan.c create mode 100755 gfm/datax.c create mode 100755 gfm/dbd360.c create mode 100755 gfm/dbd365.c create mode 100755 gfm/dbdnly.c create mode 100755 gfm/dchgs.c create mode 100755 gfm/dchix.c create mode 100755 gfm/dcmp.c create mode 100755 gfm/dcos.c create mode 100755 gfm/dcoss.c create mode 100755 gfm/dcot.c create mode 100755 gfm/dcox.c create mode 100755 gfm/dcpy.c create mode 100755 gfm/dctod.c create mode 100755 gfm/ddeg.c create mode 100755 gfm/ddiv.c create mode 100755 gfm/ddivpf.c create mode 100755 gfm/ddivpr.c create mode 100755 gfm/ddivpt.c create mode 100755 gfm/ddivr.c create mode 100755 gfm/ddivt.c create mode 100755 gfm/ddix.c create mode 100755 gfm/ddixf.c create mode 100755 gfm/ddixr.c create mode 100755 gfm/ddixt.c create mode 100755 gfm/deltrz.c create mode 100755 gfm/demo01.c create mode 100755 gfm/demo02.c create mode 100755 gfm/demo03.c create mode 100755 gfm/demo04.c create mode 100755 gfm/demo05.c create mode 100755 gfm/demo06.c create mode 100755 gfm/demo07.c create mode 100755 gfm/demo08.c create mode 100755 gfm/demo09.c create mode 100755 gfm/demo10.c create mode 100755 gfm/demo11.c create mode 100755 gfm/demo12.c create mode 100755 gfm/demo13.c create mode 100755 gfm/demo14.c create mode 100755 gfm/demo15.c create mode 100755 gfm/demo16.c create mode 100755 gfm/demo17.c create mode 100755 gfm/demo18.c create mode 100755 gfm/demo19.c create mode 100755 gfm/dexp.c create mode 100755 gfm/dexx.c create mode 100755 gfm/dfact.c create mode 100755 gfm/dfprintf.c create mode 100755 gfm/dfract.c create mode 100755 gfm/dfree.c create mode 100755 gfm/dfscanf.c create mode 100755 gfm/dftod.c create mode 100755 gfm/dftodr.c create mode 100755 gfm/dint.c create mode 100755 gfm/diseq.c create mode 100755 gfm/disge.c create mode 100755 gfm/disgt.c create mode 100755 gfm/disint.c create mode 100755 gfm/disle.c create mode 100755 gfm/dislt.c create mode 100755 gfm/disne.c create mode 100755 gfm/disneg.c create mode 100755 gfm/dispos.c create mode 100755 gfm/diszero.c create mode 100755 gfm/divarr.c create mode 100755 gfm/divarrd.c create mode 100755 gfm/divdfd.c create mode 100755 gfm/divid.c create mode 100755 gfm/divld.c create mode 100755 gfm/divstr.c create mode 100755 gfm/divuid.c create mode 100755 gfm/divuld.c create mode 100755 gfm/dllgfm.c create mode 100755 gfm/dllgfm.def create mode 100755 gfm/dllgfm.mak create mode 100755 gfm/dln.c create mode 100755 gfm/dlnx.c create mode 100755 gfm/dlog.c create mode 100755 gfm/dmag.c create mode 100755 gfm/dmant.c create mode 100755 gfm/dmax.c create mode 100755 gfm/dmby1.asm create mode 100755 gfm/dmby1.c create mode 100755 gfm/dmby1r.asm create mode 100755 gfm/dmby1r.c create mode 100755 gfm/dmbyn.asm create mode 100755 gfm/dmbyn.c create mode 100755 gfm/dmbyp10.asm create mode 100755 gfm/dmbyp10.c create mode 100755 gfm/dmbyp10t.asm create mode 100755 gfm/dmbyp10t.c create mode 100755 gfm/dmbyp10tc.c create mode 100755 gfm/dmean.c create mode 100755 gfm/dmi.asm create mode 100755 gfm/dmi.c create mode 100755 gfm/dmin.c create mode 100755 gfm/dmod.c create mode 100755 gfm/dmoddf.c create mode 100755 gfm/dmodi.c create mode 100755 gfm/dmodl.c create mode 100755 gfm/dmodui.c create mode 100755 gfm/dmodul.c create mode 100755 gfm/dmul.c create mode 100755 gfm/dmulr.c create mode 100755 gfm/dmult.c create mode 100755 gfm/dmux.c create mode 100755 gfm/dpct.c create mode 100755 gfm/dpdb.c create mode 100755 gfm/dpdbtbl.c create mode 100755 gfm/dpddb.c create mode 100755 gfm/dpddbtbl.c create mode 100755 gfm/dpow.c create mode 100755 gfm/dpowi.c create mode 100755 gfm/dpowrat.c create mode 100755 gfm/dpoxi.c create mode 100755 gfm/dprec.c create mode 100755 gfm/dprintf.c create mode 100755 gfm/dpsl.c create mode 100755 gfm/dpsltbl.c create mode 100755 gfm/dpsoy.c create mode 100755 gfm/dpsoytbl.c create mode 100755 gfm/drad.c create mode 100755 gfm/droot.c create mode 100755 gfm/drooti.c create mode 100755 gfm/dround.c create mode 100755 gfm/dscanf.c create mode 100755 gfm/dsetertn.c create mode 100755 gfm/dsign.c create mode 100755 gfm/dsin.c create mode 100755 gfm/dsins.c create mode 100755 gfm/dsort.c create mode 100755 gfm/dsprintf.c create mode 100755 gfm/dsqrt.c create mode 100755 gfm/dsqx.c create mode 100755 gfm/dsscanf.c create mode 100755 gfm/dsub.c create mode 100755 gfm/dsux.c create mode 100755 gfm/dswap.c create mode 100755 gfm/dtan.c create mode 100755 gfm/dtoa.c create mode 100755 gfm/dtoac.c create mode 100755 gfm/dtoacr.c create mode 100755 gfm/dtoaf.c create mode 100755 gfm/dtoar.c create mode 100755 gfm/dtodc.c create mode 100755 gfm/dtodf.c create mode 100755 gfm/dtoeng.c create mode 100755 gfm/dtofr.c create mode 100755 gfm/dtoi.c create mode 100755 gfm/dtol.c create mode 100755 gfm/dtosci.c create mode 100755 gfm/dtoui.c create mode 100755 gfm/dtoul.c create mode 100755 gfm/dtrunc.c create mode 100755 gfm/dtrux.c create mode 100755 gfm/dzero.c create mode 100755 gfm/dzeroarr.c create mode 100755 gfm/efftonom.c create mode 100755 gfm/errname.c create mode 100755 gfm/frtod.c create mode 100755 gfm/funname.c create mode 100755 gfm/gcmp.asm create mode 100755 gfm/gcmp.c create mode 100755 gfm/gf.h create mode 100755 gfm/gfd.h create mode 100755 gfm/gfmdefs.c create mode 100755 gfm/ginc.asm create mode 100755 gfm/ginc.c create mode 100755 gfm/gl.c create mode 100755 gfm/gm.equ create mode 100755 gfm/gm.h create mode 100755 gfm/gmec.c create mode 100755 gfm/gmef.c create mode 100755 gfm/gmfequs.h create mode 100755 gfm/gmfname.h create mode 100755 gfm/gmfncnum.h create mode 100755 gfm/gmfuncts.h create mode 100755 gfm/gmglobal.c create mode 100755 gfm/gmrs.c create mode 100755 gfm/gmserri.c create mode 100755 gfm/gmsys1.h create mode 100755 gfm/gmsystem.h create mode 100755 gfm/hmi.asm create mode 100755 gfm/hmi.c create mode 100755 gfm/import.h create mode 100755 gfm/intraux.c create mode 100755 gfm/irr.c create mode 100755 gfm/itod.c create mode 100755 gfm/libgfm.sl create mode 100755 gfm/linest.c create mode 100755 gfm/lookarr.c create mode 100755 gfm/ltod.c create mode 100755 gfm/makeasm create mode 100755 gfm/makefile create mode 100755 gfm/makefile3 create mode 100755 gfm/makelsh create mode 100755 gfm/makid.c create mode 100755 gfm/makld.c create mode 100755 gfm/makuid.c create mode 100755 gfm/makuld.c create mode 100755 gfm/maxarr.c create mode 100755 gfm/median.c create mode 100755 gfm/mgmn.asm create mode 100755 gfm/mgmn.c create mode 100755 gfm/minarr.c create mode 100755 gfm/mirr.c create mode 100755 gfm/mli.asm create mode 100755 gfm/mli.c create mode 100755 gfm/model.h create mode 100755 gfm/mul10.asm create mode 100755 gfm/mul10.c create mode 100755 gfm/mul10ad.asm create mode 100755 gfm/mul10ad.c create mode 100755 gfm/mul10l.asm create mode 100755 gfm/mul10l.c create mode 100755 gfm/mularr.c create mode 100755 gfm/mularrd.c create mode 100755 gfm/muldfd.c create mode 100755 gfm/mulid.c create mode 100755 gfm/mulld.c create mode 100755 gfm/mulstr.c create mode 100755 gfm/muluid.c create mode 100755 gfm/mululd.c create mode 100755 gfm/nfv.c create mode 100755 gfm/nomtoeff.c create mode 100755 gfm/npv.c create mode 100755 gfm/padd.c create mode 100755 gfm/pchange.c create mode 100755 gfm/pdiv.c create mode 100755 gfm/pmul.c create mode 100755 gfm/pof.c create mode 100755 gfm/predx.c create mode 100755 gfm/predy.c create mode 100755 gfm/prologue.h create mode 100755 gfm/psub.c create mode 100755 gfm/ptoy.c create mode 100755 gfm/roundcnt.c create mode 100755 gfm/scanf.c create mode 100755 gfm/scanfx.c create mode 100755 gfm/sgmn.asm create mode 100755 gfm/sgmn.c create mode 100755 gfm/simp360.c create mode 100755 gfm/simp365.c create mode 100755 gfm/simpaux.c create mode 100755 gfm/smi.asm create mode 100755 gfm/smi.c create mode 100755 gfm/spfv.c create mode 100755 gfm/sppv.c create mode 100755 gfm/sq5to4.c create mode 100755 gfm/stnddev.c create mode 100755 gfm/subarr.c create mode 100755 gfm/subarrd.c create mode 100755 gfm/subdfd.c create mode 100755 gfm/subid.c create mode 100755 gfm/subld.c create mode 100755 gfm/substr.c create mode 100755 gfm/subuid.c create mode 100755 gfm/subuld.c create mode 100755 gfm/sumarr.c create mode 100755 gfm/sumarrn.c create mode 100755 gfm/sumarrp.c create mode 100755 gfm/trunccnt.c create mode 100755 gfm/uitod.c create mode 100755 gfm/ultod.c create mode 100755 gfm/usfv.c create mode 100755 gfm/uspv.c create mode 100755 gfm/wmean.c create mode 100755 gfm/ytop.c diff --git a/gfm/adate360.c b/gfm/adate360.c new file mode 100755 index 000000000..fb5a9979c --- /dev/null +++ b/gfm/adate360.c @@ -0,0 +1,76 @@ +/* void AddDaysToDate360( m2, d2, y2, m1, d1, y1, ndays ) + * + * ARGUMENTS + * int m1, d1, y1 - Specify a base date. + * int *m2, *d2, *y2 - Specify a date to be calculated + * int ndays - Number of days (+ or -) to be added to base + * + * DESCRIPTION + * A signed number of days (ndays) is added to the base date to form a + * second date which is transferred to the variables m2,d2,y2. If any of + * the arguments are NULL on input, an error results. + * + * Years < 100 are taken to be in 20th century. + * + * All years are considered to have 12 equal months of 30 days each for + * a total of 360 days. + * + * SIDE EFFECTS + * Changes d2, m2, y2. + * + * RETURNS + * None. + * + * POSSIBLE ERROR CODES + * + * GM_ARGVAL + * GM_NULLPOINTER + * + * AUTHOR + * Don Killen 03-Feb-1988 16:27:32 + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void AddDaysToDate360(m2,d2,y2,m1,d1,y1,ndays) +int m1,*m2,d1,*d2,y1,*y2,ndays; +{ + + long day; + + _MacStart(GM_ADATE360); + + if (d2==NULL||m2==NULL||y2==NULL) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + + if ( m1<1 || m1>12 || d1<1 || d1>31 || y1<1 || y1>9999 ) { + _MacErr(GM_ARGVAL); + _MacRetV; + } + day = (long) y1 * 360L + (long) ( (m1-1)*30 + (d1-1) + ndays); + /* computes days from Jan 1, Year 0 */ + + if (day<0L) { /* no negative years */ + _MacErr(GM_ARGVAL); + _MacRetV; + } + + /* changes to m2/d2/y2 */ + *y2 = (int) (day / 360L); + day = day % 360L; + + *m2 = (int) (day) / 30 + 1; + + *d2 = (int) (day) % 30 + 1; + + _MacRetV; +} diff --git a/gfm/adate365.c b/gfm/adate365.c new file mode 100755 index 000000000..43f1237c4 --- /dev/null +++ b/gfm/adate365.c @@ -0,0 +1,144 @@ +/* void AddDaysToDate365( m2, d2, y2, m1, d1, y1, ndays ) + * + * ARGUMENTS + * int m1, d1, y1 - Specify a base date. + * int *m2, *d2, *y2 - Specify a date to be calculated + * int ndays - Number of days (+ or -) to be added to base + * + * DESCRIPTION + * A signed number of days (ndays) is added to the base date to form a + * second date which is transferred to the variables m2,d2,y2. If any of + * the arguments are NULL on input, an error results. + * + * Years < 100 are taken to be in 20th century. + * + * Years are considered to have 365 days. Leap years are considered here. + * + * SIDE EFFECTS + * Modified d2, m2, y2. + * + * RETURNS + * None. + * + * POSSIBLE ERROR CODES + * + * GM_ARGVAL + * GM_NULLPOINTER + * + * AUTHOR + * Don Killen 03-Feb-1988 16:27:32 + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void AddDaysToDate365(m2,d2,y2,m1,d1,y1,ndays) +int m1,*m2,d1,*d2,y1,*y2,ndays; +{ + long n1; + int np, x, z, mt, dt=1, dp, ny, t1, t2; + + mbool ly; + _MacStart(GM_ADATE365); + + if (d2==NULL||m2==NULL||y2==NULL) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + + if ( m1<1 || m1>12 || d1<1 || d1>31 || y1<1 || y1>9999 ) { + _MacErr(GM_ARGVAL); + _MacRetV; + } + + if (m1<=2) { + x=0; + z=y1-1; + } + else { + x=(4*m1 + 23) / 10; + z=y1; + } + + /* compute day # */ + n1 = (long) y1 * 365L + (long) (31*(m1-1) + d1 + z/4 - x) + +(long) ndays; + + /* estimate year */ + *y2 = (int) ((4L * n1) / 1461L); + np = (int) (n1 - ((long) (*y2) * 365L + (long) (((*y2) - 1) / 4))); + /* correct year estimate */ + while (np<1) { /* year too large */ + *y2 = (*y2)-1; + np = (int) (n1 - ((long)(*y2) * 365L + + (long) (((*y2)-1) / 4))); + } + if ( ((*y2) % 4) == 0) + ny = 366; + else + ny = 365; + while (np > ny ) { /* year too small */ + *y2 = (*y2)+1; + np = (int) (n1 - ((long)(*y2) * 365L + + (long) (((*y2)-1) / 4))); + } + +/* no leap year in 1700, 1800, 1900 */ + if ((y1>=1700 && y1<=1900) || (*y2>=1700 && *y2<=1900)) { + t1 = (m1<=2) ? y1-1 : y1; + t2 = (np<60) ? (*y2)-1 : *y2; + if (np==60 && ndays<0) + t2--; +/* if y1 and y2 fall on different centuries, extra leap year counted */ + np+= ((t2/100) - (t1/100)); + if (np<1) { + *y2 = *y2-1; + *m2 = 12; + *d2 = 31; + _MacRetV; + } + if (np>366) { + *y2 = *y2+1; + *m2 = 1; + *d2 = 1; + _MacRetV; + } + + } + + /* handle Jan. & Feb. */ + if (np <= 31) { + *m2 = 1; + *d2 = np; + _MacRetV; + } + + /* check for leap year */ + ly = ((*y2) % 4 == 0); + + if (np <= 59 + (ly)) { + *m2 = 2; + *d2 = np - 31; + _MacRetV; + } + + /* handle other months */ + if (ly) + np--; + mt = 2; + do { + mt++; + dp = dt; + dt = np - 31 * (mt - 1) + (4 * mt + 23) / 10; + } while (dt>=1); + *m2 = mt-1; + *d2 = dp; + + _MacRetV; +} diff --git a/gfm/adatenly.c b/gfm/adatenly.c new file mode 100755 index 000000000..a347a87d6 --- /dev/null +++ b/gfm/adatenly.c @@ -0,0 +1,109 @@ +/* void AddDaysToDate365NoLeapYear( m2, d2, y2, m1, d1, y1, ndays ) + * + * ARGUMENTS + * int m1, d1, y1 - Specify a base date. + * int *m2, *d2, *y2 - Specify a date to be calculated + * int ndays - Number of days (+ or -) to be added to base + * + * DESCRIPTION + * A signed number of days (ndays) is added to the base date to form a + * second date which is transferred to the variables m2,d2,y2. If any of + * the arguments are NULL on input, an error results. + * + * Years < 100 are taken to be in 20th century. + * + * Years are considered to have 365 days. Leap years are considered here. + * + * SIDE EFFECTS + * Modified d2, m2, y2. + * + * RETURNS + * None. + * + * POSSIBLE ERROR CODES + * + * GM_ARGVAL + * GM_NULLPOINTER + * + * AUTHOR + * Don Killen 03-Feb-1988 16:27:32 + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void AddDaysToDate365NoLeapYear(m2,d2,y2,m1,d1,y1,ndays) +int m1,*m2,d1,*d2,y1,*y2,ndays; +{ + long n1; + int np, x, mt, dt=1, dp, ny; + + _MacStart(GM_ADATENLY); + + if (d2==NULL||m2==NULL||y2==NULL) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + + if ( m1<1 || m1>12 || d1<1 || d1>31 || y1<1 || y1>9999 ) { + _MacErr(GM_ARGVAL); + _MacRetV; + } + + if (m1<=2) { + x=0; + } + else { + x=(4*m1 + 23) / 10; + } + + /* compute day # */ + n1 = (long) y1 * 365L + (long) (31*(m1-1) + d1 - x) + +(long) ndays; + + /* estimate year */ + *y2 = (int) (n1 / 365L); + np = (int) (n1 - (long) (*y2) * 365L); + /* correct year estimate */ + while (np<1) { /* year too large */ + *y2 = (*y2)-1; + np = np + 365; + } + + ny = 365; + while (np > ny) { /* year too small */ + *y2 = (*y2)+1; + np = np-365; + } + + /* handle Jan. & Feb. */ + if (np <= 31) { + *m2 = 1; + *d2 = np; + _MacRetV; + } + + if (np <= 59) { + *m2 = 2; + *d2 = np - 31; + _MacRetV; + } + + /* handle other months */ + mt = 2; + do { + mt++; + dp = dt; + dt = np - 31 * (mt - 1) + (4 * mt + 23) / 10; + } while (dt>=1); + *m2 = mt-1; + *d2 = dp; + + _MacRetV; +} diff --git a/gfm/addarr.c b/gfm/addarr.c new file mode 100755 index 000000000..d9e70c3a3 --- /dev/null +++ b/gfm/addarr.c @@ -0,0 +1,64 @@ +/* DEC **AddDecimalArrays(pDst,pSrc1,pSrc2,n) + * + * ARGUMENT + * pDst is a ptr to the array of destination DEC pointers. + * pSrc1 and pSrc2 are ptrs to the arrays of source DEC pointers + * n is the number of elements in pSrc + * + * DESCRIPTION + * Sets pDst[i] = pSrc1[i] + pSrc2[i]. If pDst is null, tries to create a + * DEC structure, then add. If some of the pSrc structures + * are null, the non-null ones are still added. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to the new structure if successful, otherwise + * returns GM_NULLARR. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC **AddDecimalArrays(pDst,pSrc1,pSrc2,n) +DEC **pDst; +DEC **pSrc1, **pSrc2; +int n; +{ + int i; + +/* source must be supplied !! */ + _MacStart(GM_ADDARR); + + if (!pSrc1 || !pSrc2 || !pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* Add the numbers */ + for (i=0; i +#include "gm.h" +#include "gmsystem.h" + +DEC **AddDecimalToDecimalArray(pDst,pSrc1,pSrc2,n) +DEC **pDst; +DEC **pSrc1, *pSrc2; +int n; +{ + int i; + DEC dcop2, *cop2=&dcop2; + mbool copyback; + +/* source must be supplied !! */ + _MacStart(GM_ADDARRD); + + _MacInVar(pSrc2, GM_NULLARR); + if (!pSrc1||!pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* Copy Src2 in case it is part of destination array */ + _MacDCopy(cop2, pSrc2); + +/* check if backwards copy is necessary */ + copyback=(pDst > pSrc1); + +/* Add the numbers */ + i = copyback ? n-1 : 0; + while ((i=0)) { + (void) AddDecimal(pDst[i], pSrc1[i], cop2); +/* AddDecimal sets the error flag each time an error occurs */ + + if (copyback) + i--; + else + i++; + } + + + _MacRet(pDst); +} diff --git a/gfm/adddfd.c b/gfm/adddfd.c new file mode 100755 index 000000000..5f315469b --- /dev/null +++ b/gfm/adddfd.c @@ -0,0 +1,57 @@ +/* DEC *AddDoubleToDecimal(pDst,pSrc1,l) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * l is the double to be added to pSrc1 + * + * DESCRIPTION + * Adds the value 'l' to pSrc1 and puts the result in dest DEC structure. + * The sum is calculated to the maximum possible accuracy. + * + * SIDE EFFECTS + * On overflow, the dest value is destroyed. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_CNVRE + * + * AUTHOR + * Andy Anderson 08-JUL-1987 1500 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AddDoubleToDecimal(pDst,pSrc1,l) +DEC *pDst,*pSrc1; +double l; +{ + DEC decS2, *pSrc2=&decS2, *pd; + + _MacStart(GM_ADDDFD); + + /* Convert the double to a DEC */ + pSrc2=ConvDoubleToDecimal(pSrc2,l); + if (!pSrc2) { + if (pDst) + _MacDCopy(pDst, pSrc1); + _MacRet(GM_NULL); + } + + pd = AddDecimal(pDst,pSrc1,pSrc2); + + _MacRet(pd); +} diff --git a/gfm/addid.c b/gfm/addid.c new file mode 100755 index 000000000..b438c1956 --- /dev/null +++ b/gfm/addid.c @@ -0,0 +1,47 @@ +/* DEC *AddIntToDecimal(pDst,pSrc1,l) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * l is the int to be added to pSrc1 + * + * DESCRIPTION + * Adds the value 'l' to pSrc1 and puts the result in dest DEC structure. + * The sum is calculated to the maximum possible accuracy. + * + * SIDE EFFECTS + * On overflow, the dest value is destroyed. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 08-JUL-1987 1500 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AddIntToDecimal(pDst,pSrc1,l) +DEC *pDst,*pSrc1; +int l; +{ + DEC *t; + + _MacStart(GM_ADDID); + + t = AddLongToDecimal(pDst,pSrc1,(long) l); + _MacRet(t); +} diff --git a/gfm/addld.c b/gfm/addld.c new file mode 100755 index 000000000..90f796496 --- /dev/null +++ b/gfm/addld.c @@ -0,0 +1,51 @@ +/* DEC *AddLongToDecimal(pDst,pSrc1,l) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * l is the long to be added to pSrc1 + * + * DESCRIPTION + * Adds the value 'l' to pSrc1 and puts the result in dest DEC structure. + * The sum is calculated to the maximum possible accuracy. + * + * SIDE EFFECTS + * On overflow, the dest value is destroyed. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 08-JUL-1987 1500 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AddLongToDecimal(pDst,pSrc1,l) +DEC *pDst,*pSrc1; +long l; +{ + DEC decS2, *pSrc2=&decS2, *pd; + + _MacStart(GM_ADDLD); + + /* Convert the long to a DEC int */ + (void) ConvLongToDecimal(pSrc2,l); + + pd = AddDecimal(pDst,pSrc1,pSrc2); + + _MacRet(pd); +} diff --git a/gfm/addstr.c b/gfm/addstr.c new file mode 100755 index 000000000..9a08cc5a6 --- /dev/null +++ b/gfm/addstr.c @@ -0,0 +1,69 @@ +/* DEC + * AddAscii(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure + * pSrc1 is a pointer to source1 ASCII string + * pSrc2 is a pointer to source2 ASCII string + * + * DEpSrcIPTION + * Adds the value in pSrc1 (ASCII) to the value in pSrc2 (ASCII) + * and puts the result in pDst DEC structure + * + * SIDE EFFECTS + * On overflow, the dest value is indeterminate. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * otherwise, returns a GM_NULL(a C false). On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLSTRING + * GM_NAN + * GM_CNVRE + * GM_CNVRW + * + * AUTHOR + * Kamy Rahimi 19-JAN-1987 10:14:48 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + + +DEC* AddAscii(pDst,pSrc1,pSrc2) +DEC *pDst; +char *pSrc1,*pSrc2; +{ + DEC t1,t2; + DEC *ps1,*ps2, *pd; + + _MacStart( GM_ADDSTR ); + + ps1=&t1; + ps2=&t2; + + ps1=ConvAsciiToDecimal(ps1,pSrc1); + if (!ps1) + _MacRet(GM_NULL); + + ps2=ConvAsciiToDecimal(ps2,pSrc2); + if (!ps2) + _MacRet(GM_NULL); + + pd = AddDecimal(pDst,ps1,ps2); + + _MacRet(pd); + +} + + + diff --git a/gfm/adduid.c b/gfm/adduid.c new file mode 100755 index 000000000..36d273b4a --- /dev/null +++ b/gfm/adduid.c @@ -0,0 +1,46 @@ +/* DEC *AddUnsToDecimal(pDst,pSrc1,l) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * l is the int to be added to pSrc1 + * + * DESCRIPTION + * Adds the value 'l' to pSrc1 and puts the result in dest DEC structure. + * The sum is calculated to the maximum possible accuracy. + * + * SIDE EFFECTS + * On overflow, the dest value is destroyed. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 08-JUL-1987 1500 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AddUnsToDecimal(pDst,pSrc1,l) +DEC *pDst,*pSrc1; +unsigned l; +{ + DEC *t; + + _MacStart(GM_ADDUID); + + t = AddLongToDecimal(pDst,pSrc1,(long) l); + _MacRet(t); +} diff --git a/gfm/adduld.c b/gfm/adduld.c new file mode 100755 index 000000000..e49408b6b --- /dev/null +++ b/gfm/adduld.c @@ -0,0 +1,50 @@ +/* DEC *AddUnsLongToDecimal(pDst,pSrc1,l) + * + * ARGUMENT + * *pDst is a pointer to the destination DEC structure. + * *pSrc1 is a ptr to the source1 DEC structure. + * l is the unsigned long to be added to pSrc1. + * + * DESCRIPTION + * Adds the value 'l' to pSrc1 and puts the result in dest DEC structure. + * The sum is calculated to the maximum possible accuracy. + * + * SIDE EFFECTS + * On overflow, the dest value is indeterminate. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 08-JUL-1987 1500 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AddUnsLongToDecimal(pDst,pSrc1,l) +DEC *pDst,*pSrc1; +unsigned long l; +{ + DEC decTemp, *pSrc2=&decTemp, *pd; + + _MacStart(GM_ADDULD); + +/* Convert the unsigned long to a DEC int */ + (void) ConvUnsLongToDecimal(pSrc2,l); + + pd = AddDecimal(pDst,pSrc1,pSrc2); + + _MacRet(pd); +} diff --git a/gfm/advpmt.c b/gfm/advpmt.c new file mode 100755 index 000000000..afc34de37 --- /dev/null +++ b/gfm/advpmt.c @@ -0,0 +1,55 @@ +/* DEC *AdvancePayment(nper, intr, pv, pmt, fv, ad, opt) + * + * ARGUMENT + * int nper, ad, opt; + * DEC *intr, *pv, *pmt, *fv; + * + * DESCRIPTION + * Given five variables involved in compound interest, solves for the + * sixth one. The variables are the number of periods nper, the percentage + * interest rate per period intr, the present value pv, the periodic payment + * pmt, the future value fv, and the number of advanced payments ad, + * while opt tells which variable to solve for. + * + * SIDE EFFECTS + * Changes value of unknown variable. + * + * RETURNS + * In case of success when not solving for nper, the result is returned. + * If solving for nper or if an error occurs, GM_NULL is returned. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AdvancePayment(nper, intr, pv, pmt, fv, ad, opt) +int nper, ad, opt; +DEC *intr, *pv, *pmt, *fv; +{ + DEC *p; + + _MacStart(GM_ADVPMT); + + if (opt==GM_N || ad>=nper || ad<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + p=_CompoundAux(0, &nper, intr, intr, pv, pmt, fv, ad, opt); + + _MacRet(p); +} diff --git a/gfm/agmn.asm b/gfm/agmn.asm new file mode 100755 index 000000000..872879067 --- /dev/null +++ b/gfm/agmn.asm @@ -0,0 +1,111 @@ + ; int _AddUnsArrToUnsArr(src1,src2,dst,n) + ; + ; ARGUMENT + ; unsigned *src1, *src2, *dst; + ; unsigned n; /* number of ints to add */ + ; + ; DESCRIPTION + ; + ; Adds src1 to scr2 giving dst. src1 and scr2 are unchanged. + ; src1, src2 and dst point to unsigned arrays. + ; + ; SIDE EFFECTS + ; dst is indeterminate on overflow. Note that although we are using + ; unsigned, we return an overflow status from here if the high-order bit + ; goes set. Caller can then determine if that is an error in his case. + ; + ; RETURNS + ; Returns GM_SUCCESS if no overflow, otherwise GM_FAILURE. + ; + ; AUTHOR + ; Andy Anderson 13-JAN-1987 13:30 + ; Copyright (C) 1987-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; Andy Anderson 16-jul-87 80-bit + ; + ; + include model.h + include prologue.h + include gm.equ + + pseg gmath +; +; if large memory model then: +; +; parm1_ = ptr to source 1 +; parm3_ = ptr to source 2; +; parm5_ = destination segment ptr +; parm6_ = destination offset ptr +; parm7_ = number of unsigned's to add +; +; for if small model then +; parm1_ = ptr to source1 +; parm2_ = ptr to source2 +; parm3_ = ptr to destination +; parm4_ = number of unsigned's to add +; + cproc _AddUnsArrToUnsArr,,agmn + +if _LDATA + push ds + push es + lds si,parm1_ ; ptr to a + les di,parm3_ ; ptr to b + mov cx,parm7_ ; number of uns's to add +else + mov si,parm1_ + mov di,parm2_ + mov cx,parm4_ + mov dx,parm3_ ; offset to dst +endif + + xor bx,bx ; clear flags and offset +addlp: +if _LDATA + mov ax,[si+bx] ; get a digit + adc ax,es:[di+bx] + push ds ; have to exchange for large model + push si + lds si,parm5_ ; destination seg:offset + mov [si+bx],ax ; mov partial product + pop si ; restore ptr to src1 + pop ds + pushf ; save overflow flag + inc bx + inc bx ; move to next unsigned + loop addlp +else + mov ax,[si+bx] ; get a digit + adc ax,[di+bx] + xchg dx,si + mov [bx+si],ax + xchg si,dx + pushf ; save overflow flag + inc bx + inc bx ; move to next unsigned + loop addlp +endif + pop bx ; get back last undisturbed flags + test bx,0800h ; mask the overflow bit + jnz overf + mov ax,GM_SUCCESS ; set SUCCESS return for caller +exit: +if _LDATA + mov cx,parm7_ +else + mov cx,parm4_ +endif + dec cx ; since we've already poped one off + sal cx,1 ; the stack, make byte offset -2 + add sp,cx ; clean up stack from pushf's +if _LDATA + pop es + pop ds +endif + cproce +overf: + mov ax,GM_FAILURE + jmp short exit + endps + END diff --git a/gfm/agmn.c b/gfm/agmn.c new file mode 100755 index 000000000..3cc95ae6a --- /dev/null +++ b/gfm/agmn.c @@ -0,0 +1,72 @@ +/* int _AddUnsArrToUnsArr(src1,src2,dst,n) + * + * ARGUMENT + * unsigned *src1, *src2, *dst; + * unsigned n; + * + * DESCRIPTION + * Adds src1 to src2 giving dst. src1 and src2 are unchanged. + * Src1, src2 and dst point to unsigned arrays. + * + * SIDE EFFECTS + * + * + * RETURNS + * GM_SUCCESS if no overflow, otherwise GM_FAILURE. + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + +int _AddUnsArrToUnsArr(src1, src2, dst, n) +unsigned SHORT src1[], src2[], dst[]; +int n; +{ + int i; + unsigned long pdst,maxunsint; + unsigned carry; + + carry=0; +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(double)BITSPERUI)-1; +#endif + + if (n>0) + { + for (i=0;imaxunsint) + { + carry=(unsigned)(pdst >> BITSPERUI ); + dst[i]=(unsigned SHORT )(pdst & maxunsint ); + } + else + { + carry=0; + dst[i]=(unsigned SHORT)pdst; + } + } + + if (dst[n-1]>>(BITSPERUI-1)) + return(GM_FAILURE); + } + + return(GM_SUCCESS); +} + diff --git a/gfm/amort.c b/gfm/amort.c new file mode 100755 index 000000000..7de91248f --- /dev/null +++ b/gfm/amort.c @@ -0,0 +1,100 @@ +/* void Amortize(payintr,payprin,balance,intr,pv,pmt,begend,time) + * + * ARGUMENT + * DEC *payintr,*payprin,*balance; + * DEC *intr, *pv, *pmt; + * int begend, time; + * + * DESCRIPTION + * For a certain payment of a loan, computes the amount of the payment + * applied towards interest (payintr), the amount of the payment applied + * towards principle (payprin), and the remaining balance (balance). The + * loan is described by its present value (pv), the payment (pmt), the + * interest rate (intr), and whether payments are at the beginning or end + * of the month (begend), while time tells the payment for which the + * calculations should be done. pv should be positive while pmt should be + * negative to obey the sign convention. The output is rounded to two + * decimal places. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void Amortize(payintr,payprin,balance,intr,pv,pmt,begend,time) +DEC *payintr,*payprin,*balance; +DEC *intr, *pv, *pmt; +int begend, time; +{ + int i; + DEC dnintr, *nintr=&dnintr, dnpmt, *npmt=&dnpmt; + + _MacStart(GM_AMORT); + + if (!payintr||!payprin||!balance||!intr||!pv||!pmt) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + + if (_MacBad(intr) || _MacBad(pv) || _MacBad(pmt)) { + _MacErr(GM_INIT); + _MacRetV; + } + + if ((begend!=GM_BEGIN&&begend!=GM_END)||time<0) { + _MacErr(GM_ARGVAL); + _MacRetV; + } + + _MacDCopy(nintr, intr); + nintr->dc.id+=2; + _ScaleDec80Bit(npmt,pmt,2); + +/* store results for payment '0' */ + _MacDZero(payintr); + _MacDZero(payprin); + (void) _ScaleDec80Bit(balance,pv,2); + + if (time==0) + _MacRetV; + +/* calculate payment 1 results */ + if (begend!=GM_BEGIN) { + (void) _MulDec80Bit(payintr, balance, nintr); + (void) _ScaleDec80Bit(payintr, payintr ,2); + if (_MacIsDecN(payintr)^_MacIsDecN(npmt)) + _MacDChgs(payintr); + } + (void) _SubDec80Bit(payprin, npmt, payintr); + (void) _SubDec80Bit(balance, balance, payprin); + +/* calculate rest of payments */ + for (i=2;i<=time;i++) { + (void) _MulDec80Bit(payintr, balance, nintr); + (void) _ScaleDec80Bit(payintr,payintr,2); + if (_MacIsDecN(payintr)^_MacIsDecN(npmt)) + _MacDChgs(payintr); + (void) _SubDec80Bit(payprin, npmt, payintr); + (void) _SubDec80Bit(balance, balance, payprin); + } + + _MacRetV; +} diff --git a/gfm/amorttbl.c b/gfm/amorttbl.c new file mode 100755 index 000000000..001eb6548 --- /dev/null +++ b/gfm/amorttbl.c @@ -0,0 +1,112 @@ +/* void AmortizeTable(payintr,payprin,balance,intr,pv,pmt,begend,time) + * + * ARGUMENT + * DEC **payintr, **payprin, **balance; + * DEC *intr, *pv, *pmt; + * int begend, time; + * + * DESCRIPTION + * For several payments of a loan, computes the amount of the payment + * applied towards interest (payintr), the amount of the payment applied + * towards principle (payprin), and the remaining balance (balance). The + * loan is described by its present value (pv), the payment (pmt), the + * interest rate (intr), and whether payments are at the beginning or end + * of the month (begend), while time tells the number of payments for which + * the calculations should be done. pv should be positive while pmt should + * be negative to obey the sign convention. The output is rounded to two + * decimal places. The results are stored in 3 arrays. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void AmortizeTable(payintr,payprin,balance,intr,pv,pmt,begend,time) +DEC **payintr, **payprin, **balance; +DEC *intr, *pv, *pmt; +int begend, time; +{ + int i, n1, n2; + DEC dnintr, *nintr=&dnintr, dnpmt, *npmt=&dnpmt; + + _MacStart(GM_AMORTTBL); + + if (!payintr||!payprin||!balance||!intr||!pv||!pmt) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + + if (_MacBad(intr) || _MacBad(pv) || _MacBad(pmt)) { + _MacErr(GM_INIT); + _MacRetV; + } + + for (i=0;i<=time;i++) + if (!payintr[i]||!payprin[i]||!balance[i]) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + + if ((begend!=GM_BEGIN&&begend!=GM_END)||time<0) { + _MacErr(GM_ARGVAL); + _MacRetV; + } + + _MacDCopy(nintr, intr); + nintr->dc.id+=2; + _ScaleDec80Bit(npmt,pmt,2); + +/* store results for payment '0' */ + _MacDZero(payintr[0]); + _MacDZero(payprin[0]); + (void) _ScaleDec80Bit(balance[0],pv,2); + + if (time==0) + _MacRetV; + +/* calculate payment 1 results */ + if (begend!=GM_BEGIN) { + (void) _MulDec80Bit(payintr[1], balance[0], nintr); + (void) _ScaleDec80Bit(payintr[1], payintr[1] ,2); + if (_MacIsDecN(payintr[1])^_MacIsDecN(npmt)) + _MacDChgs(payintr[1]); + } + else + _MacDZero(payintr[1]); + (void) _SubDec80Bit(payprin[1], npmt, payintr[1]); + (void) _SubDec80Bit(balance[1], balance[0], payprin[1]); + +/* calculate rest of payments */ + for (i=2;i<=time;i++) { + (void) _MulDec80Bit(payintr[i], balance[i-1], nintr); + (void) _ScaleDec80Bit(payintr[i],payintr[i],2); +/* for some reason, this routine failed when the _MacIsDecN & the ^ are */ +/* on the same line as the if */ + n1 = _MacIsDecN(payintr[i]); + n2 = _MacIsDecN(npmt); + if (n1 ^ n2) + _MacDChgs(payintr[i]); + (void) _SubDec80Bit(payprin[i], npmt, payintr[i]); + (void) _SubDec80Bit(balance[i], balance[i-1], payprin[i]); + } + + _MacRetV; +} diff --git a/gfm/atod.c b/gfm/atod.c new file mode 100755 index 000000000..d238f81d8 --- /dev/null +++ b/gfm/atod.c @@ -0,0 +1,245 @@ +/* DEC *ConvAsciiToDecimal(dst,src1) + * + * ARGUMENT + * dst is a pointer to the destination DEC structure. + * src1 is a ptr to the ascii string to be converted. + * + * DESCRIPTION + * Converts an ascii string to an internal format number + * and puts it into the dst DEC structure. The id is the + * number of digits past the decimal point. + * + * SIDE EFFECTS + * None. The destination structure is indeterminate if + * an overflow of significant digits occured during conversion. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow. + * Otherwise, returns a GM_NULL(a C false). On error, the error + * is in wGMError, unless an error was already there. + * Note that truncation of insignificant digits is not fatal, but + * sets a warning flag for the caller to determine if that is fatal + * for their application. + * + * POSSIBLE ERROR CODES + * + * GM_NULLSTRING + * GM_NAN + * GM_CNVRE + * GM_CNVRW + * + * AUTHOR + * Andy Anderson 13-JAN-1987 14:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * Mark Nelson 23-Jan-1990 + * Modified to handle leading and trailing whitespace, like atoi(); + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ConvAsciiToDecimal( dst, s ) +DEC *dst; +char *s; +{ + + DEC dx, *x=&dx; + int digright; + int sign, k, j, exp, expisn=0, equid, xtra=0; + mbool trwarn=FALSE; + unsigned c10; + register int i, fd; + + _MacStart(GM_ATOD); + fd = 0; + sign = 1; /* assume a positive sign */ + +/* If he hands us a null string, _MacRet error to user */ + + if (!s) { + _MacErr(GM_NULLSTRING); + _MacRet(GM_NULL); + } + + _MacOutVar(dst, GM_NULL); + +/* First strip any leading whitespace */ + + for (; s[fd] == ' ' || s[fd] == '\t' ; fd++ ) ; + +/* Then check for an empty string */ + + if (s[fd] == '\0') { + _MacErr(GM_NULLSTRING); + _MacRet(GM_NULL); + } + +/* fix sign */ + for (; ((s[fd] == '-') || (s[fd] == '+')); fd++) { + if (s[fd] == '-') + sign = -1; + } + + +/* Strip leading zeroes from the string */ + while ( s[fd] == '0' ) + fd++; + +/* Search for 'e' or 'E' signifying scientfic notation */ + + for ( j = fd; ; j++ ) { + if ( s[j] == '\0' ) + break; + if ( s[j] == 'e' ) + break; + if ( s[j] == 'E' ) + break; + if ( s[j] == ' ' ) + break; + if ( s[j] == '\t' ) + break; + } +/* If there is an exponent, calculate it or _MacRet GM_NAN */ + exp = 0; + if ((s[j] == 'e' || s[j] == 'E')) { + k=j+1; + if ((s[k]=='+') || (s[k]=='-')) { + expisn = (s[k]=='-') ? 1 : 0; + k++; + } + do { + if ((s[k]<'0') || (s[k]>'9')) { + _MacErr(GM_NAN); + _MacRet (GM_NULL); + } + exp = 10*exp + s[k] - 0x30; + k++; + } while (s[k] != 0 && s[k] != ' ' && s[k] != '\t' ); + if (expisn) + exp = -exp; + } + +/* check for bad characters */ + for (i=fd; i '9')) && (s[i] != '.') + && (s[i] != ',')) { + _MacErr(GM_NAN); + _MacRet (GM_NULL); + } + +/* set equal to 0 */ + _MacDZero(x); + x->dc.id = 0; + + if (fd == j) { + _MacDCopy(dst,x); + _MacRet(dst); + } + +/* everything else */ + digright = 0; + +/* digits before decimal point */ + for (i=fd; (i= '0') && (s[i] <= '9')) { + c10=s[i] - 0x30; + if (x->dc.sl[3] < 3276L) + (void) _MulUnsArrP10AndAddInt( + x->dc.sl, c10); + else { + if((s[i] >= '5') && wfGMRound) + /* round off */ + (void) _IncrementUnsArr( + x->dc.sl); + for (; ((s[i]!='.') && (i0) { + _MacErr(GM_CNVRE); + _MacRet(GM_NULL); + } + i=j; + trwarn=TRUE; + break; + } + } + if (s[i] == '.') { + i++; + break; + } + } + +/* digits after decimal point */ + for (; i= '0') && (s[i] <= '9')) { +/* after decimal point */ + if ((digright-expdc.sl[3]<3276L)) { +/* room for digit */ + c10=s[i] - 0x30; + (void) _MulUnsArrP10AndAddInt( + x->dc.sl, c10); + digright++; + } + else { +/* no room for digit */ + if((s[i] >= '5') && wfGMRound) { +/* round off */ + (void) _IncrementUnsArr( + x->dc.sl); + } + trwarn=TRUE; + break; + } + } + if (s[i] == '.') { +/* two decimal points */ + _MacErr(GM_NAN); + _MacRet (GM_NULL); + } + } + +/* adjust for exponential */ + equid = digright-xtra-exp; + + if ((equid>=GM_MINID) && (equid<=GM_MAXID)) + x->ls.lid=equid; + + if (equid>GM_MAXID) { + x->ls.lid=GM_MAXID; + trwarn=TRUE; + if (!_MacIsDecZ(x)) { + if (wfGMRound) + _DivUnsArrByPwrOf10( x->dc.sl, + 5, equid-GM_MAXID); + else + _DivUnsArrByPwrOf10( x->dc.sl, + 5, equid-GM_MAXID); + if (_MacIsDecZ(x)) { + _MacErr(GM_CNVRE); + } + } + } + + if (equiddc.sl, GM_MINID-equid, 5); + if ((k!=GM_SUCCESS) || (x->dc.msd!=0) + || (x->dc.sl[3] > 32767L)) { + _MacErr(GM_CNVRE); + _MacRet(GM_NULL); + } + x->dc.id=GM_MINID; + } + +/* adjust for sign */ + if (sign == -1) + _MacDChgs(x); + + _MacDCopy(dst, x); + if (trwarn) + _MacErr(GM_CNVRW); + + _MacRet(dst); +} diff --git a/gfm/atodr.c b/gfm/atodr.c new file mode 100755 index 000000000..d8fe7533c --- /dev/null +++ b/gfm/atodr.c @@ -0,0 +1,252 @@ +/* DEC *ConvAsciiToDecimalRound(dst,src1,nid) + * + * ARGUMENT + * dst is a pointer to the destination DEC structure. + * src1 is a ptr to the ascii string to be converted. + * + * DESCRIPTION + * Converts an ascii string to an internal format number + * and puts it into the dst DEC structure. The number is rounded + * to nid decimal places. + * + * SIDE EFFECTS + * None. The destination structure is indeterminate if + * an overflow of significant digits occured during conversion. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow. + * Otherwise, returns a GM_NULL(a C false). On error, the error + * is in wGMError, unless an error was already there. + * Note that truncation of insignificant digits is not fatal, but + * sets a warning flag for the caller to determine if that is fatal + * for their application. + * + * POSSIBLE ERROR CODES + * + * GM_NULLSTRING + * GM_NAN + * GM_CNVRE + * GM_CNVRW + * GM_INVALIDID + * + * AUTHOR + * Andy Anderson 13-JAN-1987 14:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * Mark Nelson 23-Jan-1990 + * Modified to handle leading and trailing whitespace, like atoi(); + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ConvAsciiToDecimalRound(dst, s, nid ) +DEC *dst; +char *s; +int nid; +{ + DEC dx, *x=&dx; + int digright; + int sign, k, j, exp, expisn=0, equid, xtra=0; + mbool trwarn=FALSE; + unsigned c10; + register int i, fd; + + _MacStart(GM_ATODR); + fd = 0; + sign = 1; /* assume a positive sign */ + +/* If he hands us a null string, _MacRet error to user */ + if (!s) { + _MacErr(GM_NULLSTRING); + _MacRet(GM_NULL); } + +/* check for valid nid */ + if ((nid < GM_MINID) || (nid > GM_MAXID)) { + _MacErr(GM_INVALIDID); + _MacRet(GM_NULL); + } + +/* handle null pointers */ + if (!dst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + +/* First strip any leading whitespace */ + + for (; s[fd] == ' ' || s[fd] == '\t' ; fd++ ) ; + +/* Then check for an empty string */ + + if (s[fd] == '\0') { + _MacErr(GM_NULLSTRING); + _MacRet(GM_NULL); + } + +/* fix sign */ + for (; ((s[fd] == '-') || (s[fd] == '+')); fd++) { + if (s[fd] == '-') + sign = -1; + } + + +/* Strip leading zeroes from the string */ + while ( s[fd] == '0' ) + fd++; + +/* Search for 'e' or 'E' signifying scientfic notation */ + for ( j = fd; ; j++ ) { + if ( s[j] == '\0' ) + break; + if ( s[j] == 'e' ) + break; + if ( s[j] == 'E' ) + break; + if ( s[j] == ' ' ) + break; + if ( s[j] == '\t' ) + break; + } + +/* If there is an exponent, calculate it or _MacRet GM_NAN */ + exp = 0; + if ((s[j] == 'e' || s[j] == 'E')) { + k=j+1; + if ((s[k]=='+') || (s[k]=='-')) { + expisn = (s[k]=='-') ? 1 : 0; + k++; + } + do { + if ((s[k]<'0') || (s[k]>'9')) { + _MacErr(GM_NAN); + _MacRet (GM_NULL); + } + exp = 10*exp + s[k] - 0x30; + k++; + } while (s[k] != 0 && s[k] != ' ' && s[k] != '\t' ); + if (expisn) + exp = -exp; + } + +/* check for bad characters */ + for (i=fd; i '9')) && (s[i] != '.') + && (s[i] != ',')) { + _MacErr(GM_NAN); + _MacRet (GM_NULL); + } + +/* set equal to 0 */ + _MacDZero(x); + x->dc.id = 0; + + if (fd == j) { + _MacDCopy(dst, x); + _MacRet(dst); + } + +/* everything else */ + digright = 0; + +/* digits before decimal point */ + for (i=fd; (i= '0') && (s[i] <= '9')) { + c10=s[i] - 0x30; + if (x->dc.sl[3] < 3276L) + (void) _MulUnsArrP10AndAddInt( + x->dc.sl, c10); + else { + if((s[i] >= '5') && wfGMRound) + /* round off */ + (void) _IncrementUnsArr( + x->dc.sl); + for (; ((s[i]!='.') && (i0) { + _MacErr(GM_CNVRE); + _MacRet(GM_NULL); + } + i=j; + trwarn=TRUE; + break; + } + } + if (s[i] == '.') { + i++; + break; + } + } + +/* digits after decimal point */ + for (; i= '0') && (s[i] <= '9')) { + /* after decimal point */ + if ((digright-expdc.sl[3]<3276L)) { + /* room for digit */ + c10=s[i] - 0x30; + (void) _MulUnsArrP10AndAddInt( + x->dc.sl, c10); + digright++; + } + else { + /* no room for digit */ + if((s[i] >= '5') && wfGMRound) { + /* round off */ + (void) _IncrementUnsArr( + x->dc.sl); + } + trwarn = TRUE; + break; + } + } + if (s[i] == '.') { + /* two decimal points */ + _MacErr(GM_NAN); + _MacRet (GM_NULL); + } + } + +/* adjust for exponential */ + equid = digright-xtra-exp; + x->ls.lid=nid; + + if (equid>nid) { + trwarn=TRUE; + if (!_MacIsDecZ(x)) { + if (wfGMRound) + _DivUnsArrByPwrOf10( x->dc.sl, + 5, equid-nid); + else + _DivUnsArrByPwrOf10Trunc( x->dc.sl, + 5, equid-nid); + if (_MacIsDecZ(x)) { + _MacErr(GM_CNVRE); + } + } + } + + if (equiddc.sl, nid-equid, 5); + if ((k!=GM_SUCCESS) || (x->dc.msd!=0) + || (x->dc.sl[3] > 32767L)) { + _MacErr(GM_CNVRE); + _MacRet(GM_NULL); + } + } + +/* adjust for sign */ + if (sign == -1) + _MacDChgs(x); + + _MacDCopy(dst, x); + + if (trwarn) + _MacErr(GM_CNVRW); + + _MacRet(dst); + +} diff --git a/gfm/bondprc.c b/gfm/bondprc.c new file mode 100755 index 000000000..0cadd16dc --- /dev/null +++ b/gfm/bondprc.c @@ -0,0 +1,131 @@ +/* DEC *BondPrice(price, acc,yield, coupon, ppy, mop, dap, yrp, mom, dam, yrm) + * + * ARGUMENT + * DEC *price; + * DEC *yield; + * DEC *coupon; + * int ppy; + * int mop, dap, yrp; + * int mom, dam, yrm; + * + * DESCRIPTION + * Calculate the price of a bond given the desired yield, coupon rate + * for receiving interest on a bond, number of payments per year, and the + * puchase and maturity dates. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * price if successful, otherwise GM_NULL + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_INIT + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * Mark Nelson + * Fixed bond pricing to accurately convert effective to nominal before + * making calculations. + * + */ + +#include +#include "gmsystem.h" +DEC *BondPrice(price,acc,yield,coupon, ppy, mop, dap, yrp, mom, dam, yrm) +DEC *price, *yield, *coupon, *acc; +int ppy, mop, dap, yrp, mom, dam, yrm; +{ + DEC dtemp, *temp=&dtemp, dtemp2, *temp2=&dtemp2; + DEC dnper, *nper=&dnper, dpmt, *pmt=&dpmt; + DEC dnyield, *nyield=&dnyield, dfvopi, *fvopi=&dfvopi; + DEC ddsc, *dsc=&ddsc, ddcs, *dcs=&ddcs; + DEC dopi, *opi=&dopi, dopinm1, *opinm1=&dopinm1; + int ndays, npay; + + _MacStart(GM_BONDPRC); + + _MacInVarD(yield); + _MacInVarD(coupon); + _MacOutVarD(price); + + if (ppy<1||ppy>12||CompareDecimal(yield,&decMinusHundred)<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + /* calculate # of periods, including partial period */ + ndays = DaysBetweenDates360(mom, dam, yrm, mop, dap, yrp); + if (ndays < 0) { + if (ndays!=GM_ARGVAL&&ndays!=GM_OVERFLOW) + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + /* calculate number of interest payments remaining */ + (void) ConvLongToDecimal(temp, (long)ppy * (long) ndays); + (void) ConvLongToDecimal(temp2, 360L); + (void) _DivDec80Bit(nper, temp, temp2); + + (void) _TruncateDec80Bit(temp, nper, 0); + npay=temp->dc.sl[0]+1; /* int number of interest payments */ + (void) _SubDec80Bit(dsc, nper, temp); /* days purchase - next int */ + (void) _SubDec80Bit(dcs, &decOne, dsc); /* days last int - purchass */ + if (_MacIsDecZ(dsc)) + _MacDZero(dcs); + + /* calculate coupon rate per period */ + (void) ConvLongToDecimal(temp2, (long)ppy); + (void) _DivDec80Bit(pmt, coupon, temp2); + + /* calculate yield per period */ + _MacDCopy( nyield, yield ); + nyield->dc.id += 2; + _AddDec80Bit( nyield, nyield, &decOne ); + _LnDec80Bit( nyield, nyield); + _DivDec80Bit( nyield, nyield, temp2 ); + _ExpDec80Bit( nyield, nyield ); + _SubDec80Bit( nyield, nyield, &decOne ); + + if (CompareDecimal(nper, &decOne)<=0) { /* < 1 period to maturity */ + (void) _AddDec80Bit(temp, &decHundred, pmt); + (void) _MulDec80Bit(temp2, dsc, nyield); + (void) _AddDec80Bit(temp2, temp2, &decOne); + (void) _DivDec80Bit(price, temp, temp2); + } + + else { /* > 1 period to maturity */ + (void) _AddDec80Bit(opi, nyield, &decOne); + (void) _IntPwrDec80Bit(opinm1, opi, -(npay-1)); + (void) _MulDec80Bit(fvopi, &decHundred, opinm1); + + if (_MacIsDecZ(nyield)) + ConvLongToDecimal(temp, (long) npay); + else { + (void) _SubDec80Bit(temp, opi, opinm1); + (void) _DivDec80Bit(temp, temp, nyield); + } + + (void) _MulDec80Bit(temp, temp, pmt); + (void) _AddDec80Bit(temp, temp, fvopi); + _MacDChgs(dsc); + (void) PowerDecimal(temp2, opi, dsc); + (void) _MulDec80Bit(price, temp, temp2); + } + + (void) _MulDec80Bit(acc, pmt, dcs); + (void) _Sq5UnsTo4Uns(acc); + if (_MacIsDecZ(dsc)) + (void) _SubDec80Bit(price, price, pmt); + else + (void) _SubDec80Bit(price, price, acc); + (void) _Sq5UnsTo4Uns(price); + + _MacRet(price); +} diff --git a/gfm/bondyld.c b/gfm/bondyld.c new file mode 100755 index 000000000..e9169953f --- /dev/null +++ b/gfm/bondyld.c @@ -0,0 +1,122 @@ +/* DEC *BondYield(yield, price, coupon, ppy, mop, dap, yrp, mom, dam, yrm) + * + * ARGUMENT + * DEC *price; + * DEC *yield; + * DEC *coupon; + * int ppy; + * int mop, dap, yrp; + * int mom, dam, yrm; + * + * DESCRIPTION + * Calculate the yield of a bond given the price, coupon rate + * for receiving interest on a bond, number of payments per year, and the + * puchase and maturity dates. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * yield if successful, otherwise GM_NULL + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_INIT + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * Mark Nelson + * Added one line to convert nominal interest rate to effective. + * + */ + +#include +#include "gmsystem.h" +DEC *BondYield(yield, price, coupon, ppy, mop, dap, yrp, mom, dam, yrm) +DEC *price, *yield, *coupon; +int ppy, mop, dap, yrp, mom, dam, yrm; +{ + DEC dtemp, *temp=&dtemp, dtemp2, *temp2=&dtemp2; + DEC dnper, *nper=&dnper, dpmt, *pmt=&dpmt; + DEC dpv, *pv=&dpv, dfv, *fv=&dfv, *p; + DEC ddsc, *dsc=&ddsc, ddcs, *dcs=&ddcs; + int ndays, npay; + + _MacStart(GM_BONDYLD); + + _MacInVarD(coupon); + _MacInVarD(price); + _MacOutVarD(yield); + + if (ppy<1||ppy>12) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + /* calculate # of periods, including partial period */ + ndays = DaysBetweenDates360(mom, dam, yrm, mop, dap, yrp); + if (ndays < 0) { + if (ndays!=GM_ARGVAL&&ndays!=GM_OVERFLOW) + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + /* calculate number of interest payments remaining */ + (void) ConvLongToDecimal(temp, (long)ppy * (long) ndays); + (void) ConvLongToDecimal(temp2, 360L); + (void) _DivDec80Bit(nper, temp, temp2); + + (void) _TruncateDec80Bit(temp, nper, 0); + npay=temp->dc.sl[0]; + (void) _SubDec80Bit(dsc, nper, temp); /* days purchase - next int */ + (void) _SubDec80Bit(dcs, &decOne, dsc); /* days last int - purchass */ + + /* calculate coupon rate per period */ + (void) ConvLongToDecimal(temp2, (long)ppy); + (void) _DivDec80Bit(pmt, coupon, temp2); + + (void) _AddDec80Bit(fv, &decHundred, pmt); + + (void) _MulDec80Bit(temp, pmt, dcs); + (void) _AddDec80Bit(pv, price, temp); + + if (CompareDecimal(nper, &decOne)<=0) { /* < 1 period to maturity */ + _DivDec80Bit(temp, fv, pv); + _SubDec80Bit(temp, temp, &decOne); + _DivDec80Bit(yield, temp, dsc); + _MulDec80Bit(yield, yield, &decHundred); + _ScaleDec80Bit(yield, yield, wIntrPrec); + } + else { /* > 1 period to maturity */ + _MacDChgs(pv); + p = _InterestAux(3, npay, dsc, yield, pv, pmt, fv, GM_BEGIN); + if (!p) + _MacRet(GM_NULL); + } +/* + * At this point, yield contains the nominal interest rate for the bond. + * This needs to be converted to the effective interest rate. Rather than + * call the NominalToEffective routine, I import most of the code. + */ + yield->dc.id += 2; + _AddDec80Bit( yield, yield, &decOne ); + if (_IntPwrDec80Bit( yield, yield, ppy ) != GM_SUCCESS ) { + _MacErr( GM_ARGVAL ); + _MacRet( GM_NULL ); + } + _SubDec80Bit( yield, yield, &decOne ); + if (yield->dc.id >= GM_MINID+2) + yield->dc.id -= 2; + else + (void) _MulUnsArrByPwrOf10(yield->dc.sl, 5, 2); + if (_Sq5UnsTo4Uns(yield)!=GM_SUCCESS) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + _MacRet(yield); +} diff --git a/gfm/build b/gfm/build new file mode 100755 index 000000000..ccac1f583 --- /dev/null +++ b/gfm/build @@ -0,0 +1,5 @@ +CCOMP=msc +LIB1=/lib/Llibgfma.a +LIB2=/lib/Llibgfmb.a +export CCOMP LIB1 LIB2 +make diff --git a/gfm/build3 b/gfm/build3 new file mode 100755 index 000000000..932f38393 --- /dev/null +++ b/gfm/build3 @@ -0,0 +1,6 @@ +CCOMP=msc3 +LIB1=/lib/386/Slibgfma.a +LIB2=/lib/386/Slibgfmb.a +FLAGS=-c +export CCOMP LIB1 LIB2 FLAGS +make -f makefile3 diff --git a/gfm/buildd3 b/gfm/buildd3 new file mode 100755 index 000000000..b00591db6 --- /dev/null +++ b/gfm/buildd3 @@ -0,0 +1,6 @@ +CCOMP=msc3 +LIB1=/lib/386/Slibgfmad.a +LIB2=/lib/386/Slibgfmbd.a +FLAGS=-d +export CCOMP LIB1 LIB2 FLAGS +make -f makefile3 diff --git a/gfm/builddos b/gfm/builddos new file mode 100755 index 000000000..b5dc4270e --- /dev/null +++ b/gfm/builddos @@ -0,0 +1,5 @@ +CCOMP=mscdos +LIB1=/usr/lib/dos/Ldlibgfma.a +LIB2=/usr/lib/dos/Ldlibgfmb.a +export CCOMP LIB1 LIB2 +make diff --git a/gfm/buildsh b/gfm/buildsh new file mode 100755 index 000000000..6ed173a99 --- /dev/null +++ b/gfm/buildsh @@ -0,0 +1 @@ +make -f makelsh diff --git a/gfm/comp.c b/gfm/comp.c new file mode 100755 index 000000000..2a94a4627 --- /dev/null +++ b/gfm/comp.c @@ -0,0 +1,51 @@ +/* DEC *CompoundInterest(nper, intr, pv, pmt, fv, begend, opt) + * + * ARGUMENT + * int *nper, begend, opt; + * DEC *intr, *pv, *pmt, *fv; + * + * DESCRIPTION + * Given four variables involved in compound interest, solves for the + * fifth one. The variables are the number of periods nper, the percentage + * interest rate per period intr, the present value pv, the periodic payment + * pmt, and the future value fv. begend specifies whether payments take + * place at the beginning or the end of each month, while opt tells which + * variable to solve for. + * + * SIDE EFFECTS + * Changes value of unknown variable. + * + * RETURNS + * In case of success when not solving for nper, the result is returned. + * If solving for nper or if an error occurs, GM_NULL is returned. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *CompoundInterest(nper, intr, pv, pmt, fv, begend, opt) +int *nper, begend, opt; +DEC *intr, *pv, *pmt, *fv; +{ + DEC *p; + + _MacStart(GM_COMP); + + p=_CompoundAux(1, nper, intr, intr, pv, pmt, fv, begend, opt); + + _MacRet(p); +} diff --git a/gfm/compaux.c b/gfm/compaux.c new file mode 100755 index 000000000..0db1b1991 --- /dev/null +++ b/gfm/compaux.c @@ -0,0 +1,384 @@ +/* DEC *_CompoundAux(fun, nperi, nperd, intr, pv, pmt, fv, begend, opt) + * + * ARGUMENT + * int fun, *nperi, begend, opt; + * DEC *nperd, *intr, *pv, *pmt, *fv; + * + * DESCRIPTION + * Given four variables involved in compound interest, solves for the + * fifth one. The variables are the number of periods nper, the percentage + * interest rate per period intr, the present value pv, the periodic payment + * pmt, and the future value fv. begend specifies whether payments take + * place at the beginning or the end of each month, while opt tells which + * variable to solve for. + * This auxillary function does the work of CompoundInterest, + * CompoundInterestSimple, CompoundInterestCompound, + * and AdvancePayment. + * + * SIDE EFFECTS + * Changes value of unknown variable. + * + * RETURNS + * In case of success when not solving for nper, the result is returned. + * If solving for nper or if an error occurs, GM_NULL is returned. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * ALGORITHM + * Solve the following formula for the unknown variable: + * 0=pv*alpha + (1+intr*begend)*pmt*[1-(1+intr)^-int(nper)]/intr + + * fv*(1+intr)^-int(nper) + * where alpha=1 for no odd period, + * alpha=1+intr*frac(nper) for an odd period with simple interest + * alpha=(1+intr)^frac(nper) for an odd period with compound interest + * + * If intr==0, the function solves + * 0 = pv + nper * pmt + fv + * If nper==0, the function solves + * 0 = pv * alpha + fv + * + * The equation can be solved in closed form for any variable except intr, + * which requires numerical methods. + * The variables used by this routine have the following meanings: + * fun: 1 if called by ComoundInterest, 2 if by CompoundInterestSimple, + * 3 if by CompoundInterestCompound, and 0 if by AdvancePayment + * nperi: integer number of periods if fun==1 + * nperd: DEC number of periods if fun==2 or fun==3 + * intr: interest rate per period + * pv: present value + * pmt: period payment + * fv: future value (balloon payment) + * begend: GM_BEGIN if payments at beginning of period, GM_END if at end + * (or if fun==0, number of advanced payments ad) + * opt: variable to solve for: GM_N, GM_PV, GM_INTR, GM_FV, GM_PMT + * + * opi: 1 + intr + * intper: integer part of nper + * fractper: fractional part of nper (if fun==2 or fun==3) + * opitmn: (1 + intr) ^ -intper + * mess: (1 + begend)[1 - (1 + intr) ^ -intper]/intr + * alpha: 1 + intr * fractper if fun==2, (1 + intr) ^ fractper if fun==3 + * pva: pv * alpha + * fvopi: fv * opitmn + * pmtm: pmt * mess + * temp, temp2: temporary DEC's + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *_CompoundAux(fun, nperi, nperd, intr, pv, pmt, fv, begend, opt) +int fun, *nperi, begend, opt; +DEC *nperd, *intr, *pv, *pmt, *fv; +{ + int intper, ad; + DEC dopi, *opi=&dopi, dfractper, *fractper=&dfractper; + DEC dmess, *mess=&dmess, dalpha, *alpha=&dalpha; + DEC dpva, *pva=&dpva, dfvopi, *fvopi=&dfvopi; + DEC dpmtm, *pmtm=&dpmtm, dopitmn, *opitmn=&dopitmn; + DEC dtemp, *temp=&dtemp, dtemp2, *temp2=&dtemp2; + DEC dnintr, *nintr=&dnintr; + DEC ddad, *dad=&ddad, dopitmna, *opitmna=&dopitmna; + + + if (!intr||!pv||!pmt||!fv||!nperd) { + _MacErr(GM_NULLPOINTER); + return(GM_NULL); + } + if ((opt!=GM_I && _MacBad(intr)) || (opt!=GM_PV && _MacBad(pv)) || + (opt!=GM_PMT && _MacBad(pmt)) || (opt!=GM_FV && _MacBad(fv))) { + _MacErr(GM_INIT); + return(GM_NULL); + } + + if ((begend!=GM_BEGIN&&begend!=GM_END&&fun!=0)|| + (opt!=GM_N&&opt!=GM_I&&opt!=GM_PV&&opt!=GM_PMT&&opt!=GM_FV)|| + (opt!=GM_I&&CompareDecimal(intr,&decMinusHundred)!=1)) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + ad = begend; + + if (opt!=GM_N) { +/* determine integer & fractional parts of nper, if in range */ + if (fun<=1) { + if (*nperi<0) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + intper=*nperi; + } + else { + if (_MacIsDecN(nperd)|| + (CompareDecimal(nperd,&decMaxTime)==1)) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + (void) _TruncateDec80Bit(temp, nperd, 0); + intper=temp->dc.sl[0]; + (void) _SubDec80Bit(fractper, nperd, temp); + } + } + + if (opt==GM_I) { + opi=_InterestAux(fun, intper, fractper, + intr, pv, pmt, fv, begend); + return(opi); + } + + _MacDCopy(nintr, intr); + nintr->dc.id+=2; + +/* opi = 1+i */ + (void) _AddDec80Bit(opi, nintr, &decOne); + + if (opt!=GM_N) { +/* handle zero interest */ + if (_MacIsDecZ(intr)) { + (void) ConvLongToDecimal(temp2, (long) intper); + + if (opt==GM_PV) { + (void) _MulDec80Bit(temp, temp2, pmt); + (void) _AddDec80Bit(temp, temp, fv); + _MacDChgs(temp); + (void) _ScaleDec80Bit(pv, temp, 2); + return(pv); + } + + if (opt==GM_FV) { + (void) _MulDec80Bit(temp, temp2, pmt); + (void) _AddDec80Bit(temp, temp, pv); + _MacDChgs(temp); + (void) _ScaleDec80Bit(fv, temp, 2); + return(fv); + } + + if (opt==GM_PMT) { + if (intper==0) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + (void) _AddDec80Bit(temp, pv, fv); + _MacDChgs(temp); + (void) _DivRndDec80Bit(pmt, temp, temp2, 2); + return(pmt); + } + } + +/* calculate alpha */ + if (fun==2) { + (void) _MulDec80Bit(temp, nintr, fractper); + (void) _AddDec80Bit(alpha, temp, &decOne); + } + if (fun==3) { + (void) _LnDec80Bit(temp, opi); + (void) _MulDec80Bit(temp, temp, fractper); + (void) _ExpDec80Bit(alpha, temp); + } + +/* handle zero nper */ + if (intper==0) { + if (opt==GM_PMT) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + if (opt==GM_PV) { + if (fun<=1) + (void) _ScaleDec80Bit(pv, fv, 2); + else + (void) _DivRndDec80Bit( + pv, fv, alpha, 2); + _MacDChgs(pv); + return(pv); + } + + if (opt==GM_FV) { + if (fun<=1) + (void) _ScaleDec80Bit(fv, pv, 2); + else { + (void) _MulDec80Bit(fv, pv, alpha); + (void) _ScaleDec80Bit(fv, fv, 2); + } + _MacDChgs(fv); + return(fv); + } + } + +/* calcuate (1+i)^-n and (1+iS)[1-(1+i)^-n]/i */ + (void) _IntPwrDec80Bit(opitmn, opi, -intper); + (void) _SubDec80Bit(temp, &decOne, opitmn); + +/* Advance payment needs (1+i)^-(n-a) */ + if (fun==0) { + (void) _IntPwrDec80Bit(opitmna, opi, -(intper-ad)); + (void) _SubDec80Bit(temp, &decOne, opitmna); + (void) ConvLongToDecimal(dad, (long) ad); + } + else + (void) _SubDec80Bit(temp, &decOne, opitmn); + + (void) _DivDec80Bit(mess, temp, nintr); + if (begend==GM_BEGIN && fun!=0) + (void) _MulDec80Bit(mess, mess, opi); + + if ((opt==GM_PMT||opt==GM_FV)) { + if (fun>1) + (void) _MulDec80Bit(pva, pv, alpha); + if (fun<=1) + _MacDCopy(pva, pv); + } + + /* calculate FV*(1+i)^-n */ + if (opt==GM_PV||opt==GM_PMT) + (void) _MulDec80Bit(fvopi, fv, opitmn); + + if (opt==GM_PV||opt==GM_FV) + (void) _MulDec80Bit(pmtm, pmt, mess); + + if (opt==GM_PV) { + (void) _AddDec80Bit(temp, pmtm, fvopi); + _MacDChgs(temp); + if (fun>1) + (void) _DivRndDec80Bit(pv, temp, alpha, 2); + if (fun==1) + (void) _ScaleDec80Bit(pv, temp, 2); + if (fun==0) { + (void) _MulDec80Bit(temp2, dad, pmt); + (void) _SubDec80Bit(temp, temp, temp2); + (void) _ScaleDec80Bit(pv, temp, 2); + } + return(pv); + } + + if (opt==GM_PMT) { + (void) _AddDec80Bit(temp, pva, fvopi); + _MacDChgs(temp); + if (fun==0) + (void) _AddDec80Bit(mess, mess, dad); + (void) _DivRndDec80Bit(pmt, temp, mess, 2); + return(pmt); + } + + if (opt==GM_FV) { + if (fun==0) { + (void) _MulDec80Bit(temp, pmt, dad); + (void) _AddDec80Bit(pva, pv, temp); + } + (void) _AddDec80Bit(temp, pva, pmtm); + _MacDChgs(temp); + (void) _DivRndDec80Bit(fv, temp, opitmn, 2); + return(fv); + } + } + + /* opt==GM_N */ +/* handle zero interest */ + if (_MacIsDecZ(intr)) { + if (_MacIsDecZ(pmt)) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + (void) _AddDec80Bit(temp, pv, fv); + _MacDChgs(temp); + + (void) _DivTrnDec80Bit(temp2, temp, pmt, 0); +/* check for exact division => don't increment */ + (void) _MulDec80Bit(mess, temp2, pmt); + if (CompareDecimal(temp,mess)!=0) + (void) _AddDec80Bit(temp2, temp2, &decOne); + + if (_MacIsDecN(temp2)||CompareDecimal(temp2,&decMaxTime)==1) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + if (fun==1) { + *nperi=temp2->dc.sl[0]; + return(GM_NULL); + } + else { + _MacDCopy(nperd, temp2); + return(nperd); + } + } + +/* first solve for integer part of period */ + (void) _DivDec80Bit(temp, pmt, nintr); + if (begend==GM_BEGIN) + (void) _MulDec80Bit(temp, temp, opi); + _MacDCopy(temp2, temp); + (void) _AddDec80Bit(temp, temp, pv); + (void) _SubDec80Bit(temp2, temp2, fv); + if (_MacIsDecZ(temp)||_MacIsDecZ(temp2)) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + (void) _DivDec80Bit(temp, temp2, temp); + if (!_MacIsDecP(temp)) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + (void) _LnDec80Bit(temp, temp); + (void) _LnDec80Bit(temp2, opi); + + (void) _DivTrnDec80Bit(temp, temp, temp2, 0); + if (_MacIsDecN(temp)||(CompareDecimal(temp,&decMaxTime)==1)) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + intper=temp->dc.sl[0]+1; + if (intper==1) + intper--; + +/* the +1 rounding assumes the ratio of logarithms is not an integer */ + if (fun==1) { + *nperi=intper; /* always round up */ + return(GM_NULL); + } + + /* fun > 1 */ + (void) ConvLongToDecimal(nperd, (long) intper); +/* zero pv makes fractional period irrelevant */ + if (_MacIsDecZ(pv)) + return(nperd); +/* now solve for fractional part & add to integer part */ + (void) _IntPwrDec80Bit(opitmn, opi, -intper); + (void) _SubDec80Bit(temp, &decOne, opitmn); + (void) _DivDec80Bit(mess, temp, nintr); + if (begend==GM_BEGIN) + (void) _MulDec80Bit(mess, mess, opi); + (void) _MulDec80Bit(pmtm, pmt, mess); + (void) _MulDec80Bit(fvopi, fv, opitmn); + (void) _AddDec80Bit(temp, pmtm, fvopi); + _MacDChgs(temp); + (void) _DivDec80Bit(alpha, temp, pv); + if (fun==2) { + (void) _SubDec80Bit(temp, alpha, &decOne); + (void) _DivDec80Bit(fractper, temp, nintr); + (void) _AddDec80Bit(nperd, nperd, fractper); + (void) _Sq5UnsTo4Uns(nperd); + } + if (fun==3) { + if (!_MacIsDecP(alpha)) + return(nperd); + (void) _LnDec80Bit(temp, alpha); + (void) _LnDec80Bit(temp2, opi); + (void) _DivDec80Bit(fractper, temp, temp2); + (void) _AddDec80Bit(nperd, nperd, fractper); + (void) _Sq5UnsTo4Uns(nperd); + } + return(nperd); +} diff --git a/gfm/compcomp.c b/gfm/compcomp.c new file mode 100755 index 000000000..9d29cf9e7 --- /dev/null +++ b/gfm/compcomp.c @@ -0,0 +1,52 @@ +/* DEC *CompoundInterestCompound(nper, intr, pv, pmt, fv, begend, opt) + * + * ARGUMENT + * int begend, opt; + * DEC *nper, *intr, *pv, *pmt, *fv; + * + * DESCRIPTION + * Given four variables involved in compound interest, solves for the + * fifth one. The variables are the number of periods nper, the percentage + * interest rate per period intr, the present value pv, the periodic payment + * pmt, and the future value fv. begend specifies whether payments take + * place at the beginning or the end of each month, while opt tells which + * variable to solve for. + * This function allows for a partial first period during which compound + * interest is computed. + * + * SIDE EFFECTS + * Changes value of unknown variable. + * + * RETURNS + * In case of success, the result is returned. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *CompoundInterestCompound(nper, intr, pv, pmt, fv, begend, opt) +int begend, opt; +DEC *nper, *intr, *pv, *pmt, *fv; +{ + DEC *p; + + _MacStart(GM_COMPCOMP); + + p=_CompoundAux(3, &opt, nper, intr, pv, pmt, fv, begend, opt); + + _MacRet(p); +} diff --git a/gfm/compsimp.c b/gfm/compsimp.c new file mode 100755 index 000000000..9bedbd1f7 --- /dev/null +++ b/gfm/compsimp.c @@ -0,0 +1,52 @@ +/* DEC *CompoundInterestSimple(nper, intr, pv, pmt, fv, begend, opt) + * + * ARGUMENT + * int begend, opt; + * DEC *nper, *intr, *pv, *pmt, *fv; + * + * DESCRIPTION + * Given four variables involved in compound interest, solves for the + * fifth one. The variables are the number of periods nper, the percentage + * interest rate per period intr, the present value pv, the periodic payment + * pmt, and the future value fv. begend specifies whether payments take + * place at the beginning or the end of each month, while opt tells which + * variable to solve for. + * This function allows for a partial first period during which simple + * interest is computed. + * + * SIDE EFFECTS + * Changes value of unknown variable. + * + * RETURNS + * In case of success, the result is returned. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *CompoundInterestSimple(nper, intr, pv, pmt, fv, begend, opt) +int begend, opt; +DEC *nper, *intr, *pv, *pmt, *fv; +{ + DEC *p; + + _MacStart(GM_COMPSIMP); + + p=_CompoundAux(2, &opt, nper, intr, pv, pmt, fv, begend, opt); + + _MacRet(p); +} diff --git a/gfm/d10by5.c b/gfm/d10by5.c new file mode 100755 index 000000000..a105fe1e8 --- /dev/null +++ b/gfm/d10by5.c @@ -0,0 +1,53 @@ +/* void _DivUns10ArrByUns5Arr(c, a, b) + * + * ARGUMENT + * unsigned c[], a[], b[]; + * + * DESCRIPTION + * Divides a 10-word by a 5-word, giving a 5-word, setting c = a / b. + * This functions assumes that b > 0 and a / b < 2^79, and will break if + * those conditions are not true. The result is always rounded off. + * It calls dmbyn and ginc. + * + * SIDE EFFECTS + * a and b may be destroyed, but they are not needed later on. + * + * RETURNS + * None. + * + * AUTHOR + * Jared Levy Aug 5, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _DivUns10ArrByUns5Arr(c, a, b) +unsigned SHORT c[], a[], b[]; +{ + register int m, n; + + n = 4; + while (b[n] == 0 && n>0) + n--; + + if (n == 0) { /* dividing by a 1 digit number */ + _DivUnsArrByUnsRound(a, b[0], 6); + for (m=0; m<5; m++) + c[m]=a[m]; + } + + else { + /* dividing by a multi digit number */ + m = 9; + while (a[m] == 0 && m>0) + m--; + + _DivUnsArrByUnsArr(c, a, m+1, b, n+1, 1); + } +} diff --git a/gfm/d10by5t.c b/gfm/d10by5t.c new file mode 100755 index 000000000..0981302a6 --- /dev/null +++ b/gfm/d10by5t.c @@ -0,0 +1,53 @@ +/* void _DivUns10ArrByUns5ArrTrn(c, a, b) + * + * ARGUMENT + * unsigned c[], a[], b[]; + * + * DESCRIPTION + * Divides a 10-word by a 5-word, giving a 5-word, setting c = a / b. + * This functions assumes that b > 0 and a / b < 2^79, and will break if + * those conditions are not true. The result is always truncated. + * It calls dmbyn. + * + * SIDE EFFECTS + * a and b may be destroyed, but they are not needed later on. + * + * RETURNS + * None. + * + * AUTHOR + * Jared Levy Aug 5, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _DivUns10ArrByUns5ArrTrn(c, a, b) +unsigned SHORT c[], a[], b[]; +{ + register int m, n; + + n = 4; + while (b[n] == 0 && n>0) + n--; + + if (n == 0) { /* dividing by a 1 digit number */ + (void) _DivUnsArrByUns(a, b[0], 6); + for (m=0; m<5; m++) + c[m]=a[m]; + } + + else { + /* dividing by a multi digit number */ + m = 9; + while (a[m] == 0 && m>0) + m--; + + _DivUnsArrByUnsArr(c, a, m+1, b, n+1, 0); + } +} diff --git a/gfm/dabs.c b/gfm/dabs.c new file mode 100755 index 000000000..849e2ec76 --- /dev/null +++ b/gfm/dabs.c @@ -0,0 +1,47 @@ +/* DEC *AbsoluteDecimal(pDst,pSrc1); + * + * ARGUMENT + * DEC *pDst,*pSrc1; + * + * DESCRIPTION + * Returns the absolute value of pSrc1 in pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pDst if successful, and returns GM_NULL on error. + * + * AUTHOR + * Andy Anderson 27-JAN-1987 19:00 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AbsoluteDecimal(pDst,pSrc) +DEC *pDst,*pSrc; +{ + + _MacStart( GM_DABS ); + + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + /* Then check for negative number */ + _MacDCopy(pDst,pSrc); + if (_MacIsDecN(pSrc)) { + _MacDChgs(pDst); + } + + _MacRet(pDst); +} diff --git a/gfm/dacos.c b/gfm/dacos.c new file mode 100755 index 000000000..a34786928 --- /dev/null +++ b/gfm/dacos.c @@ -0,0 +1,80 @@ +/* DEC *ArcCosineDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the arccosine (in radians) of pSrc, + * which always lies between 0 and pi + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_IMAG if | pSrc | > 1 + * + * AUTHOR + * Jared Levy Aug 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ArcCosineDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + int isn = 0; + DEC *nsrc, dnsrc, *temp1, dtemp1, *temp2, dtemp2; + DEC *temp3, dtemp3, *temp4, dtemp4; + + _MacStart(GM_DACOS); + + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + nsrc = &dnsrc; + _MacDCopy(nsrc, pSrc); + if (_MacIsDecN(nsrc)) { + isn = 1; + _MacDChgs(nsrc); + } + + if ((CompareDecimal(nsrc,&decOne)) == 1) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pSrc)) { + _MacDCopy(pDst,&decPiOver2); + _MacRet(pDst); + } + + (void) _MulDec80Bit(temp1= &dtemp1, nsrc, nsrc); + (void) _SubDec80Bit(temp2= &dtemp2, &decOne, temp1); + _SqrtDec80Bit(temp3=&dtemp3, temp2); + + if (_MacIsDecZ(temp3)) /* arcsin(1) = pi/2 */ + {_MacDZero(pDst);} + else { + (void) _DivDec80Bit(temp4=&dtemp4, temp3, nsrc); + _ATanDec80Bit(pDst, temp4); + } + + if (isn) + (void) _SubDec80Bit(pDst, &decPi, pDst); + + /* reduce from 80-bit back to 64-bit */ + (void) _Sq5UnsTo4Uns(pDst); + + + _MacRet(pDst); +} diff --git a/gfm/dadd.c b/gfm/dadd.c new file mode 100755 index 000000000..00d0d6c75 --- /dev/null +++ b/gfm/dadd.c @@ -0,0 +1,127 @@ +/* DEC *AddDecimal(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Adds the value in pSrc1 DEC to the value in pSrc2 DEC + * and puts the result in dest DEC structure. The sum is calculated + * to the maximum possible accuracy. The routine requires MINID, + * the minimum allowed implied decimal. + * + * SIDE EFFECTS + * On overflow, the dest value is indeterminate. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 13-JAN-1987 14:14 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gmsystem.h" + +DEC *AddDecimal(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC t1, t2, *pts; + register int i,j; + int s1, s2; + + _MacStart(GM_DADD); + + _MacInVar(pSrc1,GM_NULL); + _MacInVar(pSrc2,GM_NULL); + _MacOutVar(pDst,GM_NULL); + +/* if the source id's are different, make them equal with as much accuracy + as is possible, and protect source fields from change */ + + +/* line up decimal places */ + i = pSrc1->dc.id-pSrc2->dc.id; + if (i) { + pts = &t1; + _MacDCopy(pts, pSrc1); + pts = &t2; + _MacDCopy(pts, pSrc2); + + if (i<0) { + pSrc1 = &t1; + pSrc2 = &t2; + i = -i; + } + else { + pSrc2 = &t1; + pSrc1 = &t2; + } + + j = _MulUnsArrByPwrOf10Limited( + pSrc1->dc.sl, i, 4); + pSrc1->dc.id += j; + if (jdc.sl, 4, i-j); + } + +/* add the numbers */ + pDst->dc.id = pSrc1->dc.id; + s1 = pSrc1->dc.attr & 0x0001; + s2 = pSrc2->dc.attr & 0x0001; + + if (s1 == s2) { +/* add absolute values if signs are equal */ + _AddUnsArrToUnsArr(pSrc1->dc.sl, pSrc2->dc.sl, + pDst->dc.sl,5); + + /* if the first addition is an overflow, round down and try again */ + if (pDst->dc.sl[3] >= 32768L) { + if (pSrc1->dc.id <= GM_MINID) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + _DivUnsArrByUns(pDst->dc.sl, 10, 4); + pDst->dc.id--; + } + + /* sign of pDst same as sign of sources */ + pDst->dc.attr = s1; + } + + else { +/* subtract larger absolute value from smaller if signs are different */ + if (_CompareUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, 4) >= 0) { + /* pSrc1 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc1 */ + pDst->dc.attr = s1; + } + + else { + /* pSrc2 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc2->dc.sl, + pSrc1->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc2 */ + pDst->dc.attr = s2; + } + } + + _MacRet(pDst); +} diff --git a/gfm/dadx.c b/gfm/dadx.c new file mode 100755 index 000000000..eb9730ba8 --- /dev/null +++ b/gfm/dadx.c @@ -0,0 +1,110 @@ +/* int _AddDec80Bit(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Adds the value in pSrc1 DEC to the value in pSrc2 DEC + * and puts the result in dest DEC structure. The sum is calculated + * to the maximum possible accuracy. The routine requires GM_IMINID, + * the minimum allowed implied decimal. + * + * SIDE EFFECTS + * On overflow, the *pDst value is indeterminate. + * + * RETURNS + * Returns GM_SUCCESS if no error, else failure code. + * + * Note: uses an assembly language routine for the actual math + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _AddDec80Bit(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC t1, t2, *pts; + register int i, j; + int s1, s2; + + i = pSrc1->dc.id-pSrc2->dc.id; + if (i) { + pts = &t1; + _MacDCopy(pts, pSrc1); + pts = &t2; + _MacDCopy(pts, pSrc2); + + if (i<0) { + pSrc1 = &t1; + pSrc2 = &t2; + i = -i; + } + else { + pSrc2 = &t1; + pSrc1 = &t2; + } + + j = _MulUnsArrByPwrOf10Limited(pSrc1->dc.sl, i, 5); + pSrc1->dc.id += j; + if (jdc.sl, 5, i-j); + } + +/* add the numbers */ + pDst->dc.id = pSrc1->dc.id; + s1 = pSrc1->dc.attr & 0x0001; + s2 = pSrc2->dc.attr & 0x0001; + + if (s1 == s2) { +/* add absolute values if signs are equal */ + _AddUnsArrToUnsArr(pSrc1->dc.sl, pSrc2->dc.sl, + pDst->dc.sl,5); + + /* if the first addition is an overflow, round down and try again */ + if (pDst->dc.sl[4] >= 32768L) { + if (pSrc1->dc.id <= GM_IMINID) + return(GM_OVERFLOW); + _DivUnsArrByUns(pDst->dc.sl, 10, 5); + pDst->dc.id--; + } + + /* sign of pDst same as sign of sources */ + pDst->dc.attr = s1; + } + + else { +/* subtract larger absolute value from smaller if signs are different */ + if (_CompareUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, 5) >= 0) { + /* pSrc1 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc1 */ + pDst->dc.attr = s1; + } + + else { + /* pSrc2 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc2->dc.sl, + pSrc1->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc2 */ + pDst->dc.attr = s2; + } + } + + return(GM_SUCCESS); +} diff --git a/gfm/dalloc.c b/gfm/dalloc.c new file mode 100755 index 000000000..b8bf3352b --- /dev/null +++ b/gfm/dalloc.c @@ -0,0 +1,54 @@ +/* DEC *AllocateDecimal(); + * + * ARGUMENT + * None. + * + * DESCRIPTION + * Creates a DEC structure and zeroes it. The id is set to 2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to the new structure if allocation is successful, + * otherwise returns GM_NULL. wGMError contains GM_NOMEMORY if no previous + * error existed. + * + * POSSIBLE ERROR CODES + * + * GM_NOMEMORY + * + * AUTHOR + * Andy Anderson 14-JAN-1987 16:15 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +#ifndef DOS +extern char *calloc(unsigned ,unsigned ); +#endif + +DEC *AllocateDecimal() +{ + DEC *a; + + _MacStart(GM_DALLOC); + a=(DEC *) calloc(1,sizeof(DEC)); + + /* then make sure we pass back a good value */ + if(!a) { + _MacErr(GM_NOMEMORY); + _MacRet(GM_NULL); + } + + _MacDZero(a); + _MacRet(a); + +} diff --git a/gfm/dalog.c b/gfm/dalog.c new file mode 100755 index 000000000..09a0214a4 --- /dev/null +++ b/gfm/dalog.c @@ -0,0 +1,98 @@ +/* DEC *AntiLog10Decimal(pDst,pSrc) + * + * ARGUMENT + * pDst is a DEC pointer to the destination. + * pSrc is a DEC pointer to the source. + * + * DESCRIPTION + * Takes the base 10 anti-logarithm (power) of pSrc, + * ie. 10**x, storing result in pDst. + * + * RETURNS + * pDst if successful, GM_NULL otherwise. + * + * ALGORITHM + * Set e**x = 10 ** y, then x*ln(e) = y*ln10. Then, ln(e)=1 by + * definition, so x = y*ln(10), or y times a constant. Therefore, we + * set z=y*ln(10), and 10**y = e**z. + * + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Andy Anderson 8-18-87 13:51 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AntiLog10Decimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + int i; + DEC dtemp, *temp=&dtemp, *pt, t1; + + _MacStart(GM_DALOG); + + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + /* 10**0 is a one by definition */ + if(_MacIsDecZ(pSrc)) { + pt=&decOne; + _MacDCopy(pDst,pt); + _MacRet(pDst); + } + + pt=&t1; + _MacDZero(pt); + + /* if the power is integer and small enough, use int power rtn */ + if((IsDecimalInt(pSrc)) && ((pSrc->dc.msd == 0) && + (pSrc->ls.lsl[1] == 0L) && (pSrc->dc.sl[1] == 0)) + && (!(pSrc->dc.sl[0] & 0x8000))) { + pt->dc.id = 0; + pt->dc.sl[0] = 10; + i = _IntPwrDec80Bit(pt,pt,ConvDecimalToInt(pSrc)); + if(i != GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + } + else { + + /* first create z = y*ln10, overflow impossible */ + (void) _MulDec80Bit(temp,pSrc,&decLn10); + + /* then e**(yln10) = 10**y */ + i = _ExpDec80Bit(pt, temp); + if(i==GM_OVERFLOW) { + _MacErr(i); + _MacRet(GM_NULL); + } + + } + + i = _Sq5UnsTo4Uns(pt); /* reduce to 18-digit */ + if(i!=GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pt)) { + _MacErr(GM_UNDERFLOW); + } + + _MacDCopy(pDst,pt); + _MacRet(pDst); +} diff --git a/gfm/daralloc.c b/gfm/daralloc.c new file mode 100755 index 000000000..e788a9aa4 --- /dev/null +++ b/gfm/daralloc.c @@ -0,0 +1,81 @@ +/* DEC **AllocateDecimalArray(dst, n); + * + * ARGUMENT + * int n; + * DEC **dst; + * + * DESCRIPTION + * Creates an array of n DEC pointers, each pointing to a DEC structure. + * All of the DEC structures are zeroed with in id of 2. If dst is null, + * both the pointers and the structures are allocated. Otherwise, when dst + * is not null, only the structures are allocated and each pointer points to + * the corresponding DEC structure. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to the new structure if allocation is successful, + * otherwise returns GM_NULLARR. + * + * POSSIBLE ERROR CODES + * + * GM_NOMEMORY + * GM_ARGVAL (if n == 0) + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include + +#include "gm.h" +#include "gmsystem.h" + +#ifndef DOS +extern char *calloc(unsigned ,unsigned ); +#endif + +DEC **AllocateDecimalArray(dst, n) +int n; +DEC **dst; +{ + DEC *b, *p; + int i; + + _MacStart(GM_DARALLOC); + + if (n<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + + if (!dst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + + b = (DEC *) calloc(n,sizeof(DEC)); + +/* insufficient room for pointers */ + if(!b) { + _MacErr(GM_NOMEMORY); + _MacRet(GM_NULLARR); + } + + for (i=0; i +#include "gm.h" +#include "gmsystem.h" + +DEC **CopyDecimalArray(pDst,pSrc,n) +DEC **pDst; +DEC **pSrc; +int n; +{ + int i; + mbool copyback; /* whether list is copied backwards */ + +/* source must be supplied !! */ + _MacStart(GM_DARCPY); + + if (!pSrc||!pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* if n is 0 there's nothing to do */ + if (n==0) + _MacRet(pDst); + +/* allow for overlapping arrays */ + copyback = (pDst > pSrc); + +/* At any rate, copy the structure */ + i = copyback ? n-1 : 0; + while ((i=0)) { + (void) CopyDecimal(pDst[i], pSrc[i]); +/* CopyDecimal sets error flag if error occurs */ + if (copyback) + i--; + else + i++; + } + + _MacRet(pDst); +} diff --git a/gfm/darfree.c b/gfm/darfree.c new file mode 100755 index 000000000..6dba82fc9 --- /dev/null +++ b/gfm/darfree.c @@ -0,0 +1,61 @@ +/* void FreeDecimalArray(pSrc1) + * + * ARGUMENT + * pSrc1 is a ptr to an array of source DEC pointers. + * + * DESCRIPTION + * Returns storage to DOS via free(). + * + * SIDE EFFECTS + * Does NOT CHECK to see if spaces was allocated via malloc(). + * Therefore, DOS will lock up cause cold reboot if unallocated + * space is freed + * + * RETURNS + * None. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 17-JAN-1987 14:35 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +void FreeDecimalArray(pSrc1) +DEC **pSrc1; +{ +#ifdef LATTICE + void free(); +#else + void free(void*); +#endif + + DEC *p; + _MacStart(GM_DARFREE); + +/* Can't free null pointers */ + if(!pSrc1) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + + p = *pSrc1; +#ifdef LATTICE + free((char *) p); +#else + free((char *) p); +#endif + + _MacRetV; +} diff --git a/gfm/dasin.c b/gfm/dasin.c new file mode 100755 index 000000000..a8edbaf31 --- /dev/null +++ b/gfm/dasin.c @@ -0,0 +1,74 @@ +/* DEC *ArcSineDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the arcsine (in radians) of pSrc, + * which always lies between -pi/2 and pi/2. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_IMAG if | pSrc | > 1 + * + * AUTHOR + * Jared Levy Aug 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ArcSineDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + int isn = 0; + DEC *nsrc, dnsrc, *temp1, dtemp1, *temp2, dtemp2; + DEC *temp3, dtemp3, *temp4, dtemp4; + + _MacStart(GM_DASIN); + + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + nsrc = &dnsrc; + _MacDCopy(nsrc, pSrc); + if (_MacIsDecN(nsrc)) { + isn = 1; + _MacDChgs(nsrc); + } + + if ((CompareDecimal(nsrc,&decOne)) == 1) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + + (void) _MulDec80Bit(temp1= &dtemp1, nsrc, nsrc); + (void) _SubDec80Bit(temp2= &dtemp2, &decOne, temp1); + _SqrtDec80Bit(temp3=&dtemp3, temp2); + + if (_MacIsDecZ(temp3)) /* arcsin(1) = pi/2 */ + _MacDCopy(pDst, &decPiOver2); + else { + (void) _DivRndDec80Bit(temp4=&dtemp4, nsrc, temp3, 23); + _ATanDec80Bit(pDst, temp4); + } + + /* reduce from 80-bit back to 64-bit */ + (void) _Sq5UnsTo4Uns(pDst); + + if (isn) + _MacDChgs(pDst); + + _MacRet(pDst); +} diff --git a/gfm/datan.c b/gfm/datan.c new file mode 100755 index 000000000..c26117efe --- /dev/null +++ b/gfm/datan.c @@ -0,0 +1,47 @@ +/* DEC *ArcTangentDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the arctangent (in radians) of pSrc, + * which always lies between -pi/2 and pi/2. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * + * AUTHOR + * Jared Levy Aug 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ArcTangentDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + + _MacStart(GM_DATAN); + + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + _ATanDec80Bit(pDst, pSrc); + + /* reduce from 80-bit back to 64-bit */ + (void) _Sq5UnsTo4Uns(pDst); + + _MacRet(pDst); +} diff --git a/gfm/datax.c b/gfm/datax.c new file mode 100755 index 000000000..d1edab1c9 --- /dev/null +++ b/gfm/datax.c @@ -0,0 +1,83 @@ +/* void _ATanDec80Bit(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the arctangent (in radians) of pSrc, + * which always lies between -pi/2 and pi/2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. (always successful) + * + * AUTHOR + * Jared Levy Aug 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * ALGORITHM + * For x < 0, atan(x) = - atan(-x) + * For x > 1 atan(x) = pi / 2 - acot(x) = pi / 2 - atan(1 / x) + * atan(x) = pi / 6 + atan [ (x - 1/3^.5) / (1 + x/3^.5) ] + * atan(x) = x - x^3/3 + x^5/5 - ... + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _ATanDec80Bit(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + int isn=0, isrecip=0; + DEC *nsrc, dnsrc, *x, dx, *xsq, dxsq, *xpow, dxpow; + DEC *term, dterm, *fact, dfact; + DEC *num, dnum, *den, dden, *temp, dtemp; + + nsrc = &dnsrc; + _MacDCopy(nsrc, pSrc); + if (_MacIsDecN(nsrc)) { + isn = 1; + _MacDChgs(nsrc); + } + + if (CompareDecimal(nsrc,&decOne) == 1) { + isrecip = 1; + (void) _DivRndDec80Bit(nsrc, &decOne, nsrc, 23); + } + + (void) _SubDec80Bit(num = &dnum, nsrc, &decReciprocalOfSqrt3); + (void) _MulDec80Bit(temp = &dtemp, &decReciprocalOfSqrt3, nsrc); + (void) _AddDec80Bit(den = &dden, temp, &decOne); + (void) _DivRndDec80Bit(x = &dx, num, den, 23); + + (void) _MulDec80Bit(xsq = &dxsq, x , x); + (void) _MulDec80Bit(xpow = &dxpow, xsq, x); + _MacDCopy(pDst, x); + (void) ConvLongToDecimal(fact = &dfact, 3L); + (void) _DivRndDec80Bit(term = &dterm, xpow, fact, 23); + while (!_MacIsDecZ(term)) { + if ((fact->dc.sl[0] % 4) == 1) + (void) _AddDec80Bit(pDst, pDst, term); + else + (void) _SubDec80Bit(pDst, pDst, term); + fact->dc.sl[0]+= 2; + (void) _MulDec80Bit(xpow, xpow, xsq); + (void) _DivRndDec80Bit(term, xpow, fact, 23); + } + + (void) _AddDec80Bit(pDst, &decPiOver6, pDst); + + if (isrecip) + (void) _SubDec80Bit(pDst, &decPiOver2, pDst); + + if (isn) + _MacDChgs(pDst); +} diff --git a/gfm/dbd360.c b/gfm/dbd360.c new file mode 100755 index 000000000..26fbe3a68 --- /dev/null +++ b/gfm/dbd360.c @@ -0,0 +1,59 @@ +/* int DaysBetweenDates360(m1,d1,y1, m2,d2,y2) + * + * ARGUMENT + * int m1,d1,y1; - Base Date + * int m2,d2,y2; - Date to compare with base + * + * DESCRIPTION + * Compares two dates in date args format, forming the difference in + * whole days. The result is a signed number: + * + * In this one, all months are 30 days (e.g. year is 360 days). + * + * 0 if dates are same, + * +n if date1 > date2 + * -n if date1 < date2 + * + * SIDE EFFECTS + * None. + * + * RETURNS + * +,-, or 0 days. 0 can indicate an error. + * + * POSSIBLE ERROR CODES + * GM_ARGVAL + * GM_OVERFLOW + * + * AUTHOR + * 05-Aug-1987 12:43:39 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + */ +#include +#include "gmsystem.h" + +int DaysBetweenDates360(m1,d1,y1,m2,d2,y2) +int m1,d1,y1,m2,d2,y2; +{ + long n; + + _MacStart(GM_DBD360); + if (m1<1||m1>12||d1<1||d1>31||y1<0||y1>9999|| + m2<1||m2>12||d2<1||d2>31||y2<0||y2>9999) { + _MacErr(GM_ARGVAL); + _MacRet(0); + } + + if (d2==31) + d2=30; + if (d1==31 && d2>=30) + d1=30; + n = (long) (y1-y2) * 360L + (long) ((m1 - m2) * 30 + (d1 - d2)); + if (n<-32768L || n>32767L) { + _MacErr(GM_OVERFLOW); + _MacRet(0); + } + + _MacRet((int) n); +} diff --git a/gfm/dbd365.c b/gfm/dbd365.c new file mode 100755 index 000000000..66fa95ff8 --- /dev/null +++ b/gfm/dbd365.c @@ -0,0 +1,143 @@ +/* int DaysBetweenDates365(m1,d1,y1, m2,d2,y2) + * + * ARGUMENT + * int m1,d1,y1; - Base Date + * int m2,d2,y2; - Date to compare with base + * + * DESCRIPTION + * Compares two dates in date args format, forming the difference in + * whole days. The result is a signed number: + * + * 0 if dates are same, + * +n if date1 > date2 + * -n if date1 < date2 + * + * SIDE EFFECTS + * None. + * + * RETURNS + * +,-, or 0 days. 0 can indicate an error. + * + * POSSIBLE ERROR CODES + * GM_ARGVAL + * GM_OVERFLOW + * + * AUTHOR + * 05-Aug-1987 12:43:39 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * 01-Jan-1989 Corrected for true Gregorian Calendar + * + * DISCUSSION + * + * It may not be entirely clear when reading this code just what is going + * on. First of all, the calendar used is the Greenleaf version of the + * Gregorian calendar. We assume in this calendar that Gregorian time + * extends backwards to the year 0, and forward forever, more or less. + * A leap year occurs every four years. Except when the year is evenly + * divisible by 100, like the year 1900, when there is no leap year. Except + * when the year is evenly divisible by 400, in which case there really + * is a leap year. + * + * The way this algorithm works is relatively simple. There are four + * mysterious variables in this program: n1, n2, x and z. n1 and n2 are + * relatively easy to understand. These variables are simple the number + * of days since January 1, year 0. The difference between these two numbers + * is the actual number returned by this function. + * + * In order to calculate the number of days since 1/1/0, we can start by + * adding 365 days per year: + * + * n = 365 * y + * + * This gets a pretty good rough number, but it doesn't take into account + * the leap years. Given the Greenleaf Gregorian calendar, we can add in + * all the days accounted for by leap years like this: + * + * n = 365 * y + y/4 - y/100 + y/400 + * + * This works pretty well, but it leaves us with one problem: we are + * adding in a leap day in leap years, even if the month is January + * or February. On January 1, 1984, we haven't hit the leap day yet, so + * we shouldn't add it in. This is where z comes from. y is the actual + * year, but z is the year used for calculation of leap days: + * + * if ( m <= 2 ) + * z = y - 1; + * else + * z = y; + * n = 365 * y + y/4 - y/100 + y/400 + * + * At this point, n is accurate for January 1 of the given year. Now we + * have to add in the days accounted for by the months in the selected year. + * A good guess on how to do this is to just add 31 days per month: + * + * n = 365 * y + y/4 - y/100 + y/400 + 31*(m - 1) + * + * The only problem is that starting with month 3, there will be errors + * in the calculation. The good news is that a simple formula will generate + * a correction factor, which is x. The formula for x is (4*m + 23) / 10. + * This just happens to generate the correct sequence of numbers. A different + * way would be to create an x array {0, 0, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7}; + * So now my formula looks like this: + * + * if ( m <= 2 ) { + * x = 0; + * z = y - 1; + * } else { + * z = y; + * x = ( 4 * m + 23 ) / 10 ; + * } + * n = 365 * y + y/4 - y/100 + y/400 + 31*(m - 1) + * + * The final step is to add in the day of the month, to account for all the + * days in the current month. Do that and you are done. + * + */ + +#include +#include "gmsystem.h" + +int DaysBetweenDates365(m1,d1,y1,m2,d2,y2) +int m1,d1,y1,m2,d2,y2; +{ + long n1, n2, n; + int x, z; + + _MacStart(GM_DBD365); + + if (m1<1||m1>12||d1<1||d1>31||y1<0||y1>9999|| + m2<1||m2>12||d2<1||d2>31||y2<0||y2>9999) { + _MacErr(GM_ARGVAL); + _MacRet(GM_ARGVAL); + } + + if (m1<=2) { + x=0; + z=y1-1; + } else { + x=(4*m1 + 23) / 10; + z=y1; + } + n1 = (long) y1 * 365L + (long) (31*(m1-1) + d1 + z/4 - z/100 + z/400 - x); + + if (m2<=2) { + x=0; + z=y2-1; + } else { + x=(4*m2 + 23) / 10; + z=y2; + } + n2 = (long) y2 * 365L + (long) (31*(m2-1) + d2 + z/4 - z/100 + z/400 - x); + + n = n1 - n2; + + if (n<-32768L||n>32767L) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_OVERFLOW); + } + + _MacRet((int) n); +} diff --git a/gfm/dbdnly.c b/gfm/dbdnly.c new file mode 100755 index 000000000..e2e210545 --- /dev/null +++ b/gfm/dbdnly.c @@ -0,0 +1,74 @@ +/* int DaysBetweenDates365NoLeapYear(m1,d1,y1, m2,d2,y2) + * + * ARGUMENT + * int m1,d1,y1; - Base Date + * int m2,d2,y2; - Date to compare with base + * + * DESCRIPTION + * Compares two dates in date args format, forming the difference in + * whole days. The result is a signed number: + * + * 0 if dates are same, + * +n if date1 > date2 + * -n if date1 < date2 + * + * A 365 day calendar without leap years is used. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * +,-, or 0 days. 0 can indicate an error. + * + * POSSIBLE ERROR CODES + * GM_ARGVAL + * GM_OVERFLOW + * + * AUTHOR + * 05-Aug-1987 12:43:39 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + */ +#include +#include "gmsystem.h" + +int DaysBetweenDates365NoLeapYear(m1,d1,y1,m2,d2,y2) +int m1,d1,y1,m2,d2,y2; +{ + long n1, n2, n; + int x; + + _MacStart(GM_DBDNLY); + + if (m1<1||m1>12||d1<1||d1>31||y1<0||y1>9999|| + m2<1||m2>12||d2<1||d2>31||y2<0||y2>9999) { + _MacErr(GM_ARGVAL); + _MacRet(GM_ARGVAL); + } + + if (m1<=2) { + x=0; + } + else { + x=(4*m1 + 23) / 10; + } + n1 = (long) y1 * 365L + (long) (31*(m1-1) + d1 - x); + + if (m2<=2) { + x=0; + } + else { + x=(4*m2 + 23) / 10; + } + n2 = (long) y2 * 365L + (long) (31*(m2-1) + d2 - x); + + n = n1 - n2; + + if (n<-32768L||n>32767L) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_OVERFLOW); + } + + _MacRet((int) n); +} diff --git a/gfm/dchgs.c b/gfm/dchgs.c new file mode 100755 index 000000000..d40b6d70e --- /dev/null +++ b/gfm/dchgs.c @@ -0,0 +1,47 @@ +/* DEC *ChangeSignDecimal(pDst,pSrc1) + * + * ARGUMENT + * DEC* pDst ptr to the destination DEC structure. + * DEC* pSrc1 ptr to the source1 DEC structure. + * + * DESCRIPTION + * Sets pDst=-(pSrc1). + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to the DEC structure unless overflow. + * GM_NULL if an overflow occurs. + * + * POSSIBLE ERROR CODES: + * + * GM_NULLPOINTER + * GM_NOMEMORY + * + * AUTHOR + * Andy Anderson 13-JAN-1987 17:20 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ChangeSignDecimal(pDst,pSrc) +DEC *pDst,*pSrc; +{ + + _MacStart(GM_DCHGS); + + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + _MacDCopy(pDst,pSrc); + _MacDChgs(pDst); + + _MacRet(pDst); +} diff --git a/gfm/dchix.c b/gfm/dchix.c new file mode 100755 index 000000000..0fffedccd --- /dev/null +++ b/gfm/dchix.c @@ -0,0 +1,61 @@ +/* int _ScaleDec80Bit(pDst,pSrc1,wID) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * wID is the integer specifying location of implied decimal + * for the conversion. + * + * DESCRIPTION + * Adjusts the number in pSrc1 (if necessary) while copying it to + * pDst adjusting pDst to wID number of decimal places. If pDst is null + * on entry, tries to first create a pDst, then the conversion. + * + * SIDE EFFECTS + * pSrc1 remains unchanged, pDst is undefined on error. + * + * RETURNS + * Returns GM_SUCCESS unless there is an error, + * in which case it returns the error code. + * + * + * AUTHOR + * Andy Anderson 27-JAN-1987 19:25 + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _ScaleDec80Bit(pDst,pSrc1,wID) +DEC *pDst, *pSrc1; +int wID; +{ + register int i; + + _MacDCopy(pDst,pSrc1); + + i = pSrc1->ls.lid - wID; + + /* Make sure there's an adjustment to do */ + if(i == 0) { + return(GM_SUCCESS); + } + + /* set implied decimal */ + pDst->ls.lid = wID; + if(i>0) { + _DivUnsArrByPwrOf10( pDst->dc.sl,5,i); + } + else { + if((_MulUnsArrByPwrOf10( pDst->dc.sl, -i, 5) + != GM_SUCCESS) || (pDst->dc.msd & 0x8000)) + return(GM_OVERFLOW); + } + + return(GM_SUCCESS); +} diff --git a/gfm/dcmp.c b/gfm/dcmp.c new file mode 100755 index 000000000..7aae2ef2a --- /dev/null +++ b/gfm/dcmp.c @@ -0,0 +1,76 @@ +/* int CompareDecimal(pSrc1,pSrc2) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Compares pSrc1:pSrc2 and returns the result of the compare. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns 0 if pSrc1==pSrc2, 1 if pSrc1>pSrc2 and -1 if pSrc2>pSrc1. + * However, returns GM_NULLPOINTER if pSrc1 or pSrc2 point to a null. + * + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 14-JAN-1987 14:27 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int CompareDecimal(pSrc1,pSrc2) +DEC *pSrc1,*pSrc2; +{ + int i; + DEC dt,*pt=&dt; + + _MacStart(GM_DCMP); + + _MacInVarI(pSrc1); + _MacInVarI(pSrc2); + + if (_MacIsDecZ(pSrc2)) + _MacRet(TestSignDecimal(pSrc1)); + + if (_MacIsDecZ(pSrc1)) + _MacRet(-TestSignDecimal(pSrc2)); + + if (_MacIsDecN(pSrc1)^_MacIsDecN(pSrc2)) + _MacRet(_MacIsDecP(pSrc1) ? 1 : -1); + + if (pSrc1->dc.id == pSrc2->dc.id) { + i=_CompareUnsArr( pSrc1->dc.sl, + pSrc2->dc.sl,5); + _MacRet(_MacIsDecP(pSrc1) ? i : -i); + } + + if (pSrc1->dc.id > pSrc2->dc.id) { + i= _ScaleDec80Bit(&dt, pSrc2, pSrc1->dc.id); + if (i != GM_SUCCESS) + _MacRet(-TestSignDecimal(pSrc2)); + i=_CompareUnsArr( pSrc1->dc.sl, + pt->dc.sl,5); + _MacRet(_MacIsDecP(pSrc1) ? i : -i); + } + + /* pSrc1->dc.id < pSrc2->dc.id */ + i= _ScaleDec80Bit(&dt, pSrc1, pSrc2->dc.id); + if (i != GM_SUCCESS) + _MacRet(TestSignDecimal(pSrc1)); + i=_CompareUnsArr( pt->dc.sl, + pSrc2->dc.sl,5); + _MacRet(_MacIsDecP(pSrc2) ? i : -i); +} diff --git a/gfm/dcos.c b/gfm/dcos.c new file mode 100755 index 000000000..285c389ad --- /dev/null +++ b/gfm/dcos.c @@ -0,0 +1,46 @@ +/* DEC *CosineDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the cosine of pSrc radians. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy Oct 16, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *CosineDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; + +{ + _MacStart(GM_DCOS); + + _MacInVarD(pDst); + _MacOutVarD(pSrc); + + _CosDec80Bit(pDst, pSrc); + (void) _Sq5UnsTo4Uns(pDst); + + _MacRet(pDst); +} diff --git a/gfm/dcoss.c b/gfm/dcoss.c new file mode 100755 index 000000000..4300b4778 --- /dev/null +++ b/gfm/dcoss.c @@ -0,0 +1,56 @@ +/* void _CosDecSmall(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst, *pSrc; + * + * DESCRIPTION + * Sets pDst = cos(pSrc), where 0 <= pSrc < pi / 4. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * ALGORITHM + * Using the Taylor series, + * cos(x) = 1 - x^2/2! + x^4/4! - ... + * + * AUTHOR + * Jared Levy April 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _CosDecSmall(pDst,pSrc) +DEC *pDst, *pSrc; +{ + DEC *srcsq, dsrcsq, *term, dterm, *fact, dfact; + SHORT i; + + srcsq = &dsrcsq; + (void) _MulDec80Bit(srcsq, pSrc, pSrc); + (void) ConvLongToDecimal(pDst, 1L); + term = &dterm; + (void) _MulDec80Bit(term, srcsq, &decPoint5); + i = 2; + fact = ConvLongToDecimal(&dfact, 6L); + while (!(_MacIsDecZ(term))) { + if ((i % 4) == 0) + (void) _AddDec80Bit(pDst, pDst, term); + else + (void) _SubDec80Bit(pDst, pDst, term); + i+=2; + _MulDec80Bit(term, term, srcsq); + fact->dc.sl[0] = i * (i - 1); + _DivRndDec80Bit(term, term, fact, 23); + } + +} + diff --git a/gfm/dcot.c b/gfm/dcot.c new file mode 100755 index 000000000..286b1fb45 --- /dev/null +++ b/gfm/dcot.c @@ -0,0 +1,97 @@ +/* DEC *CotangentDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the cotangent of pSrc radians. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_IMAG if pSrc = 0 + * + * AUTHOR + * Jared Levy Oct 16, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * ALGORITHM + * tan(x) = +/- (1 - cos(x) ^ 2 ) ^ .5 / cos(x) + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *CotangentDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; + +{ + int i, isn=0; + DEC *nsrc, dnsrc, *size, dsize, *temp, dtemp; + DEC *cosx, dcosx, *sinx, dsinx; + + _MacStart(GM_DCOT); + + _MacInVarD(pSrc) + _MacOutVarD(pDst); + + if(_MacIsDecZ(pSrc)) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + + nsrc = &dnsrc; + (void) _SubDec80Bit(nsrc, &decPiOver2, pSrc); + if (_MacIsDecN(nsrc)) { + isn = 1; + _MacDChgs(nsrc); + } + + temp = &dtemp; + if (CompareDecimal(nsrc, &decPiOver2) == 1) { + (void) _DivRndDec80Bit(size = &dsize, nsrc, &decPi, 0); + (void) _MulDec80Bit(temp, &decPi, size); + (void) _SubDec80Bit(nsrc, nsrc, temp); + if (_MacIsDecN(nsrc)) { + isn = 1 - isn; + _MacDChgs(nsrc); + } + } + + _CosDec80Bit(cosx = &dcosx, nsrc); + if (_MacIsDecZ(cosx)) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + (void) _MulDec80Bit(temp, cosx, cosx); + (void) _SubDec80Bit(temp, &decOne, temp); + _SqrtDec80Bit(sinx = &dsinx, temp); + i = _DivDec80Bit(pDst, sinx, cosx); + + if (i == GM_OVERFLOW) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + i = _Sq5UnsTo4Uns(pDst); + if (i != GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (isn) + _MacDChgs(pDst); + + _MacRet(pDst); +} diff --git a/gfm/dcox.c b/gfm/dcox.c new file mode 100755 index 000000000..5df6436b2 --- /dev/null +++ b/gfm/dcox.c @@ -0,0 +1,67 @@ +/* void _CosDec80Bit(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst, *pSrc; + * + * DESCRIPTION + * Sets pDst = the cosine of pSrc radians. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. No errors are possible. + * + * AUTHOR + * Jared Levy October 16, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _CosDec80Bit(pDst,pSrc) +DEC *pDst, *pSrc; +{ + DEC dnsrc, *nsrc, dtemp, *temp; + int isn=0; + + nsrc = &dnsrc; + _MacDCopy(nsrc, pSrc); + +/* scale nsrc to range 0 to pi */ + if (_MacIsDecN(nsrc)) + _MacDChgs(nsrc); + + if (CompareDecimal(nsrc, &decPi) == 1) { + temp = &dtemp; + (void) _DivRndDec80Bit(temp, nsrc, &dec2Pi, 0); + (void) _MulDec80Bit(temp, temp, &dec2Pi); + (void) _SubDec80Bit(nsrc, nsrc, temp); + if (_MacIsDecN(nsrc)) + _MacDChgs(nsrc); + } + +/* scale nsrc to range 0 to pi / 2 */ + if (CompareDecimal(nsrc, &decPiOver2) == 1) { + isn = 1; + (void) _SubDec80Bit(nsrc, &decPi, nsrc); + } + +/* calculate appropriate Taylor series */ + if (CompareDecimal(nsrc, &decPiOver4) == 1) { + (void) _SubDec80Bit(nsrc, &decPiOver2, nsrc); + _SinDecSmall(pDst, nsrc); /* sine series */ + } + else + _CosDecSmall(pDst, nsrc); /* cosine series */ + +/* adjust for negative values */ + if (isn) + _MacDChgs(pDst); + +} diff --git a/gfm/dcpy.c b/gfm/dcpy.c new file mode 100755 index 000000000..d1dcfd8ee --- /dev/null +++ b/gfm/dcpy.c @@ -0,0 +1,49 @@ +/* DEC *CopyDecimal(pDst,pSrc1) + * + * ARGUMENT + * pDst is a ptr to the source1 DEC structure. + * pSrc1 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Copies pSrc1 to pDst. If pDst is null, tries to create a + * DEC structure, then do the copy. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to the new structure if successful, otherwise + * returns GM_NULL. If pSrc1 point to a null, returns GM_NULLPOINTER. + * + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 15-JAN-1987 18:45 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *CopyDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + +/* source must be supplied !! */ + _MacStart(GM_DCPY); + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + _MacDCopy(pDst,pSrc); + + _MacRet(pDst); + +} diff --git a/gfm/dctod.c b/gfm/dctod.c new file mode 100755 index 000000000..dec2d1ba1 --- /dev/null +++ b/gfm/dctod.c @@ -0,0 +1,63 @@ +/* DEC *ConvDollarsAndCentsToDecimal( x, d, c) + * + * ARGUMENT + * DEC *x; output + * long l; dollars + * int c; cents + * + * DESCRIPTION + * Converts d dollars and c cents to a DEC with implied decimal 2. + * + * SIDE EFFECTS + * x is indeterminate on error. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy Oct. 10, 1989 + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gmsystem.h" + +DEC *ConvDollarsAndCentsToDecimal( x, d, c) +DEC *x; +long d; +int c; +{ + int isneg=0; + + _MacStart(GM_DCTOD); + _MacOutVarD(x); + + if (d<0) { + isneg = 1; + d = -d; + c = (c<0) ? -c : c; + } + + x->ls.lmsd = 0; + x->ls.lsl[1] = 0L; + if (d<=21470000L) + x->ls.lsl[0] = d * 100L + (long) c; + else { + x->ls.lsl[0] = d; + _MulUnsArrByPwrOf10(x->dc.sl, 2, 3); + x->ls.lsl[0] += (long) c; + if (x->ls.lsl[0] < (unsigned long) c && c>0) + x->ls.lsl[1]--; + } + + x->ls.lid = 2; + x->ls.lattr = isneg; + + _MacRet(x); +} diff --git a/gfm/ddeg.c b/gfm/ddeg.c new file mode 100755 index 000000000..a4af2fb1f --- /dev/null +++ b/gfm/ddeg.c @@ -0,0 +1,46 @@ +/* DEC *ConvRadiansToDegrees(deg, rad); + * + * ARGUMENT + * DEC *deg; + * DEC *rad; + * + * DESCRIPTION + * Converts an angle rad, in radians, to degrees, + * storing the result in deg. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * rad if successful, otherwise GM_NULL + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_INIT + * GM_OVERFLOW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ +#include +#include "gmsystem.h" +DEC *ConvRadiansToDegrees(deg, rad) +DEC *deg; +DEC *rad; +{ + int i; + + _MacStart(GM_DDEG); + i = _MulDec80Bit( deg, &dec180OverPi, rad ); + if ( i != GM_SUCCESS ) { + _MacErr( i ); + _MacRet( GM_NULL ); + } + (void) _Sq5UnsTo4Uns( deg ); + _MacRet( deg ); +} diff --git a/gfm/ddiv.c b/gfm/ddiv.c new file mode 100755 index 000000000..c397768ef --- /dev/null +++ b/gfm/ddiv.c @@ -0,0 +1,60 @@ +/* DEC *DivideDecimal(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * + * DESCRIPTION + * Divides pSrc1 by pSrc2, storing the result in pDst. The quotient is + * calculated to as much accuracy as posssible, subject to the constraint + * that its implied decimal must lie between MINID and MAXID. + * + * SIDE EFFECTS + * pDst is indeterminate on underflow or overflow. + * GM_OVERFLOW: quotient too large. + * GM_UNDERFLOW: pSrc1 != 0, pSrc2 != 0, pDst = 0. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError doesn't contain a previous error. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gmsystem.h" + +DEC *DivideDecimal(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + int i; + + _MacStart(GM_DDIV); + + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + _MacOutVarD(pDst); + + i = _DivDecFast(pDst, pSrc1, pSrc2); + if (i != GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + + _MacRet(pDst); + +} diff --git a/gfm/ddivpf.c b/gfm/ddivpf.c new file mode 100755 index 000000000..92345ac3d --- /dev/null +++ b/gfm/ddivpf.c @@ -0,0 +1,149 @@ +/* int _DivProcFast(c,a,b); + * + * ARGUMENT + * DEC *c; + * DEC *a,b; + * + * DESCRIPTION + * This routine divides one positive DEC structure by another, setting + * dst = src1 / src2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * ALGORITHM + * a = an * 10^-ad + * b = bn * 10^-bd + * c = a / b + * c = (10^p * an / bn) * 10^[-(ad - bd + p)] + * cn = 10^p * an / bn, cd = ad - bd + p + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _DivProcFast(c,a,b) +DEC *c; +DEC *a,*b; +{ + register int i,t; + int maxp, p=0, mag2a, mag2b; + unsigned SHORT an[14], bn[6], *cn, ad[5], as[14]; + +/* sets c = a / b, + where a and b are positive DEC numbers, and the result is stored in c */ + + bn[0]=b->dc.sl[0]; + bn[1]=b->dc.sl[1]; + bn[2]=b->dc.sl[2]; + bn[3]=b->dc.sl[3]; + bn[4]=b->dc.msd; + bn[5]=0; + + cn = c->dc.sl; + + an[0]=a->dc.sl[0]; + an[1]=a->dc.sl[1]; + an[2]=a->dc.sl[2]; + an[3]=a->dc.sl[3]; + an[4]=a->dc.msd; + an[5] = 0; + an[6] = 0; + an[7] = 0; + an[8] = 0; + an[9] = 0; + an[10]= 0; + an[11]= 0; + + maxp = GM_MAXID - (a->dc.id - b->dc.id); + if (maxp > 0) { + +/* The following code uses up most of the time involved in divisions. +It starts with two 64-bit number integers an and bh, both positive, +along with an integer maxp. Two values are returned: a nonnegative +integer p and a 160-bit number as = an * 10^p. p is the largest number +satisfying the conditions (1) as < 2^160, + (2) the highest 80 bits of as are less than bh + (3) p <= maxp. +*/ + + i = 4; + while (an[i] == 0) + i--; + mag2a = 16 * i; + t = an[i]>>1; + while (t) { + t=t>>1; + mag2a++; + } + + i = 4; + while ((bn[i] == 0) && (i>0)) + i--; + mag2b = 16 * i; + t = bn[i]>>1; + while (t) { + t=t>>1; + mag2b++; + } + + p = (78 - 16 + mag2b - mag2a) * 3 / 10; + if (p>maxp) + p=maxp; + + + if (p != 0) + _MulUnsArrByPwrOf10(an,p,10); + + if (p != maxp) { + + for(i=0; i<14; i++) { + as[i] = an[i]; + } + + i = _MulUnsArrByPwrOf10(as,1,10); + + ad[0]=as[4]; + ad[1]=as[5]; + ad[2]=as[6]; + ad[3]=as[7]; + ad[4]=as[8]; + _DoubleUnsArr(ad, 5); + if (as[4]&0x8000) + ad[0]=ad[0]+1; + + if ((i == GM_SUCCESS) && + (_CompareUnsArr(ad,bn,5) == -1)) { + p++; + for(i=0; i<10; i++) + an[i] = as[i]; + } + } + /* p != maxp */ + + } /* maxp > 0 */ + + _DivUns10ArrByUns5Arr(cn,an,bn); + +/* adjust implied decimal to correct value */ + i = a->dc.id - b->dc.id + p; + if (iGM_MAXID) { + _DivUnsArrByPwrOf10(cn, 5, i-GM_MAXID); + i = GM_MAXID; + } + c->dc.id = i; + return(GM_SUCCESS); +} diff --git a/gfm/ddivpr.c b/gfm/ddivpr.c new file mode 100755 index 000000000..4c9386e69 --- /dev/null +++ b/gfm/ddivpr.c @@ -0,0 +1,86 @@ +/*int _DivProcRnd(c,a,b,ida,idb,nid) + * + * ARGUMENT + * DEC *c; + * unsigned a[], b[]; + * int ida,idb,nid; + * + * DESCRIPTION + * This routine divides one positive DEC structure by another, setting + * dst = src1 / src2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * GM_SUCCESS or error code. + * + * ALGORITHM + * a = an * 10^-ad + * b = bn * 10^-bd + * c = a / b + * c = (10^p * an / bn) * 10^[-(ad - bd + p)] + * cn = 10^p * an / bn, cd = ad - bd + p + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _DivProcRnd(c,a,b,ida,idb,nid) +DEC *c; +unsigned SHORT a[], b[]; +int ida,idb,nid; +{ + + int i, p; + unsigned SHORT *cn, ad[5]; + +/* sets c = a / b, + where a and b are positive DEC numbers, and the result is stored in c */ + + cn = c->dc.sl; + + p = nid - (ida - idb); + + a[5] = 0; + a[6] = 0; + a[7] = 0; + a[8] = 0; + a[9] = 0; + a[10]= 0; + a[11]= 0; + + if (p<0) + _DivUnsArrByPwrOf10(a,5,-p); + + if (p>0) { + i = _MulUnsArrByPwrOf10(a,p,10); + + /* check for overflow */ + ad[0]=a[5]; + ad[1]=a[6]; + ad[2]=a[7]; + ad[3]=a[8]; + ad[4]=a[9]; + _DoubleUnsArr(ad, 5); + if (a[4]&0x8000) + ad[0]=ad[0]+1; + + if (!((i == GM_SUCCESS) && + (_CompareUnsArr(ad,b,5) == -1))) + return(GM_OVERFLOW); + } + + _DivUns10ArrByUns5Arr(cn, a, b); + + c->dc.id = nid; + return(GM_SUCCESS); +} diff --git a/gfm/ddivpt.c b/gfm/ddivpt.c new file mode 100755 index 000000000..aba7ee5f0 --- /dev/null +++ b/gfm/ddivpt.c @@ -0,0 +1,86 @@ +/*int _DivProcTrn(c,a,b,ida,idb,nid) + * + * ARGUMENT + * DEC *c; + * unsigned a[], b[]; + * int ida,idb,nid; + * + * DESCRIPTION + * This routine divides one positive DEC structure by another, setting + * dst = src1 / src2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * GM_SUCCESS or error code. + * + * ALGORITHM + * a = an * 10^-ad + * b = bn * 10^-bd + * c = a / b + * c = (10^p * an / bn) * 10^[-(ad - bd + p)] + * cn = 10^p * an / bn, cd = ad - bd + p + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _DivProcTrn(c,a,b,ida,idb,nid) +DEC *c; +unsigned SHORT a[], b[]; +int ida,idb,nid; +{ + + int i, p; + unsigned SHORT *cn, ad[5]; + +/* sets c = a / b, + where a and b are positive DEC numbers, and the result is stored in c */ + + cn = c->dc.sl; + + p = nid - (ida - idb); + + a[5] = 0; + a[6] = 0; + a[7] = 0; + a[8] = 0; + a[9] = 0; + a[10]= 0; + a[11]= 0; + + if (p<0) + _DivUnsArrByPwrOf10Trunc(a,5,-p); + + if (p>0) { + i = _MulUnsArrByPwrOf10(a,p,10); + + /* check for overflow */ + ad[0]=a[5]; + ad[1]=a[6]; + ad[2]=a[7]; + ad[3]=a[8]; + ad[4]=a[9]; + _DoubleUnsArr(ad, 5); + if (a[4]&0x8000) + ad[0]=ad[0]+1; + + if (!((i == GM_SUCCESS) && + (_CompareUnsArr(ad,b,5) == -1))) + return(GM_OVERFLOW); + } + + _DivUns10ArrByUns5ArrTrn(cn, a, b); + + c->dc.id = nid; + return(GM_SUCCESS); +} diff --git a/gfm/ddivr.c b/gfm/ddivr.c new file mode 100755 index 000000000..b67dd2908 --- /dev/null +++ b/gfm/ddivr.c @@ -0,0 +1,75 @@ +/* DEC *DivideDecimalAndRound(dst,src1,src2,nid); + * + * ARGUMENT + * DEC *dst; + * DEC *src1,*src2; + * int nid; + * + * DESCRIPTION + * Divides src1 by src2, storing the result in dst. The quotient is + * calculated to nid decimal places. + * + * RETURNS + * Returns pointer to dst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError doesn't contain a previous error. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * GM_INVALIDID + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DivideDecimalAndRound(dst,src1,src2,nid) +DEC *dst; +DEC *src1,*src2; +int nid; +{ + int i; + + _MacStart(GM_DDIVR); + _MacInVarD(src1); + _MacInVarD(src2); + _MacOutVarD(dst); + + if ((nid > GM_MAXID) || (nid < GM_MINID)){ + _MacErr(GM_INVALIDID); + _MacRet (GM_NULL); + } + + if (_MacIsDecZ(src2)) { + _MacErr(GM_DIV0); + _MacRet(GM_NULL); + } + + i = _DivRndDec80Bit(dst, src1, src2, nid); + +/* check if number can fit into 64 bits (no shifting allowed) */ + if (!((dst->dc.msd == 0) && (dst->dc.sl[3] < 32768L))) + i = GM_OVERFLOW; + + if (i != GM_SUCCESS) { + _MacErr(i); + if (i != GM_UNDERFLOW) { + _MacRet(GM_NULL); + } + } + + _MacRet(dst); + +} diff --git a/gfm/ddivt.c b/gfm/ddivt.c new file mode 100755 index 000000000..c2a584cdd --- /dev/null +++ b/gfm/ddivt.c @@ -0,0 +1,74 @@ +/* DEC *DivideDecimalAndTruncate(dst,src1,src2,nid); + * + * ARGUMENT + * DEC *dst; + * DEC *src1,*src2; + * int nid; + * + * DESCRIPTION + * Divides src1 by src2, storing the result in dst. The quotient is + * calculated to nid decimal places. + * + * RETURNS + * Returns pointer to dst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError doesn't contain a previous error. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * GM_INVALIDID + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DivideDecimalAndTruncate(dst,src1,src2,nid) +DEC *dst; +DEC *src1,*src2; +int nid; +{ + int i; + + _MacStart(GM_DDIVT); + _MacInVarD(src1); + _MacInVarD(src2); + _MacOutVarD(dst); + + if ((nid > GM_MAXID) || (nid < GM_MINID)){ + _MacErr(GM_INVALIDID); + _MacRet (GM_NULL); + } + + if (_MacIsDecZ(src2)) { + _MacErr(GM_DIV0); + _MacRet(GM_NULL); + } + + i = _DivTrnDec80Bit(dst, src1, src2, nid); + +/* check if number can fit into 64 bits (no shifting allowed) */ + if (!((dst->dc.msd == 0) && (dst->dc.sl[3] < 32768L))) + i = GM_OVERFLOW; + + if (i != GM_SUCCESS) { + _MacErr(i); + if (i != GM_UNDERFLOW) { + _MacRet(GM_NULL); + } + } + + _MacRet(dst); + +} diff --git a/gfm/ddix.c b/gfm/ddix.c new file mode 100755 index 000000000..526872b65 --- /dev/null +++ b/gfm/ddix.c @@ -0,0 +1,151 @@ +/* int _DivDec80Bit(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * + * DESCRIPTION + * Divides pDst = pSrc1 / pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns GM_SUCCESS if successful, otherwise the error code. + * wGMError is not changed. + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _DivDec80Bit(c,a,b) +DEC *c; +DEC *a,*b; +{ + register int i,t; + int maxp, p=0, mag2a, mag2b; + unsigned SHORT an[14], bn[6], *cn, ad[5], as[14]; + + /* check that b is nonzero */ + if (_MacIsDecZ(b)) + return(GM_DIV0); + + /* check whether scr1 is zero */ + if (_MacIsDecZ(a)) { + _MacDCopy(c,a); + return(GM_SUCCESS); + } + +/* sets c = a / b, + where a and b are positive DEC numbers, and the result is stored in c */ + + bn[0]=b->dc.sl[0]; + bn[1]=b->dc.sl[1]; + bn[2]=b->dc.sl[2]; + bn[3]=b->dc.sl[3]; + bn[4]=b->dc.msd; + bn[5]=0; + + cn = c->dc.sl; + + an[0]=a->dc.sl[0]; + an[1]=a->dc.sl[1]; + an[2]=a->dc.sl[2]; + an[3]=a->dc.sl[3]; + an[4]=a->dc.msd; + an[5] = 0; + an[6] = 0; + an[7] = 0; + an[8] = 0; + an[9] = 0; + an[10]= 0; + an[11]= 0; + + maxp = GM_IMAXID - (a->dc.id - b->dc.id); + if (maxp > 0) { + +/* The following code uses up most of the time involved in divisions. +It starts with two 64-bit number integers an and bh, both positive, +along with an integer maxp. Two values are returned: a nonnegative +integer p and a 160-bit number as = an * 10^p. p is the largest number +satisfying the conditions (1) as < 2^160, + (2) the highest 80 bits of as are less than bh + (3) p <= maxp. +*/ + + i = 4; + while (an[i] == 0) + i--; + mag2a = 16 * i; + t = an[i]>>1; + while (t) { + t=t>>1; + mag2a++; + } + + i = 4; + while ((bn[i] == 0) && (i>0)) + i--; + mag2b = 16 * i; + t = bn[i]>>1; + while (t) { + t=t>>1; + mag2b++; + } + + p = (78 + mag2b - mag2a) * 3 / 10; + if (p>maxp) + p=maxp; + + + if (p != 0) + _MulUnsArrByPwrOf10(an,p,10); + + if (p != maxp) { + + for(i=0; i<14; i++) { + as[i] = an[i]; + } + + i = _MulUnsArrByPwrOf10(as,1,10); + + ad[0]=as[5]; + ad[1]=as[6]; + ad[2]=as[7]; + ad[3]=as[8]; + ad[4]=as[9]; + _DoubleUnsArr(ad, 5); + if (as[4]&0x8000) + ad[0]=ad[0]+1; + + if ((i == GM_SUCCESS) && + (_CompareUnsArr(ad,bn,5) == -1)) { + p++; + for(i=0; i<10; i++) + an[i] = as[i]; + } + } + /* p != maxp */ + } /* maxp > 0 */ + + _DivUns10ArrByUns5Arr(cn,an,bn); + +/* adjust implied decimal to correct value */ + i = a->dc.id - b->dc.id + p; + if (idc.id = i; + +/* if the signs of the sources are different, c=-c */ + c->dc.attr = (a->dc.attr^b->dc.attr); + + return(GM_SUCCESS); +} diff --git a/gfm/ddixf.c b/gfm/ddixf.c new file mode 100755 index 000000000..965953af0 --- /dev/null +++ b/gfm/ddixf.c @@ -0,0 +1,57 @@ +/* int _DivDecFast(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * + * DESCRIPTION + * Divides pDst = pSrc1 / pSrc2, to 64 bits of accuracy. + * This code is about 1/3 faster than ddix. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns GM_SUCCESS if successful, otherwise the error code. + * wGMError is not changed. + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" +int _DivProcFast(); + +int _DivDecFast(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + + /* check that pSrc2 is nonzero */ + if (_MacIsDecZ(pSrc2)) + return(GM_DIV0); + + /* check whether scr1 is zero */ + if (_MacIsDecZ(pSrc1)) { + _MacDCopy(pDst, pSrc1); + return(GM_SUCCESS); + } + + if (_DivProcFast(pDst,pSrc1,pSrc2) != GM_SUCCESS) + return(GM_OVERFLOW); + + /* if quotient is zero, an underflow has occured */ + if (_MacIsDecZ(pDst)) + return(GM_UNDERFLOW); + +/* if the signs of the sources are different, pDst=-pDst */ + pDst->dc.attr=pSrc1->dc.attr^pSrc2->dc.attr; + + return(GM_SUCCESS); +} diff --git a/gfm/ddixr.c b/gfm/ddixr.c new file mode 100755 index 000000000..9918b4564 --- /dev/null +++ b/gfm/ddixr.c @@ -0,0 +1,63 @@ +/* int _DivRndDec80Bit(pDst,pSrc1,pSrc2,wID); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * int wID; + * + * DESCRIPTION + * Divides pDst = pSrc1 / pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns GM_SUCCESS if successful, otherwise the error code. + * wGMError is not changed. + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _DivRndDec80Bit(pDst,pSrc1,pSrc2,wID) +DEC *pDst; +DEC *pSrc1,*pSrc2; +int wID; +{ + int i; + unsigned SHORT s1[14], s2[11]; /* need extra memory */ + + /* check whether scr1 is zero */ + if (_MacIsDecZ(pSrc1)) { + _MacDZero(pDst); + pDst->dc.id = wID; + return(GM_SUCCESS); + } + + for(i=0;i<5;i++) { + s1[i]=pSrc1->dc.sl[i]; + s2[i]=pSrc2->dc.sl[i]; + } + s2[5]=0; + + if(_DivProcRnd(pDst,s1,s2,pSrc1->dc.id,pSrc2->dc.id, + wID) != GM_SUCCESS) + return(GM_OVERFLOW); + + /* if quotient is zero, an underflow has occured */ + if (_MacIsDecZ(pDst)) + return(GM_UNDERFLOW); + +/* if the signs of the sources are different, pDst=-pDst */ + pDst->dc.attr = (pSrc1->dc.attr^pSrc2->dc.attr); + + return(GM_SUCCESS); +} diff --git a/gfm/ddixt.c b/gfm/ddixt.c new file mode 100755 index 000000000..2b54d117c --- /dev/null +++ b/gfm/ddixt.c @@ -0,0 +1,67 @@ +/* int _DivTrnDec80Bit(pDst,pSrc1,pSrc2,wID); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * int wID; + * + * DESCRIPTION + * Divides pDst = pSrc1 / pSrc2, truncating result to wId decimal places. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns GM_SUCCESS if successful, otherwise the error code. + * wGMError is not changed. + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _DivTrnDec80Bit(pDst,pSrc1,pSrc2,wID) +DEC *pDst; +DEC *pSrc1,*pSrc2; +int wID; +{ + int i; + unsigned SHORT s1[14], s2[12]; /* need extra memory */ + + /* check that pSrc2 is nonzero */ + if (_MacIsDecZ(pSrc2)) + return(GM_DIV0); + + /* check whether scr1 is zero */ + if (_MacIsDecZ(pSrc1)) { + _MacDZero(pDst); + pDst->dc.id = wID; + return(GM_SUCCESS); + } + + for(i=0;i<5;i++) { + s1[i]=pSrc1->dc.sl[i]; + s2[i]=pSrc2->dc.sl[i]; + } + s2[5]=0; + + if(_DivProcTrn(pDst,s1,s2,pSrc1->dc.id,pSrc2->dc.id, + wID) != GM_SUCCESS) + return(GM_OVERFLOW); + + /* if quotient is zero, an underflow has occured */ + if (_MacIsDecZ(pDst)) + return(GM_UNDERFLOW); + +/* if the signs of the sources are different, pDst=-pDst */ + pDst->dc.attr = (pSrc1->dc.attr^pSrc2->dc.attr); + + return(GM_SUCCESS); +} diff --git a/gfm/deltrz.c b/gfm/deltrz.c new file mode 100755 index 000000000..f86e7565a --- /dev/null +++ b/gfm/deltrz.c @@ -0,0 +1,55 @@ +/* DEC *DeleteTrailingZeroes(pDst, pSrc) + * + * ARGUMENT + * DEC *pSrc; + * DEC *pDst; + * + * DESCRIPTION + * Changes the interal representation of pSrc without changing its value + * by removing any trailing zeroes, if possible, and storing the result in + * pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DeleteTrailingZeroes(pDst, pSrc) +DEC *pSrc; +DEC *pDst; +{ + DEC dTemp, *pTemp=&dTemp; + unsigned i=0; + + _MacStart(GM_DELTRZ); + + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + _MacDCopy(pTemp, pSrc); + + while ((i==0) && (pTemp->dc.id>0)) { + _MacDCopy(pDst, pTemp); + i = _DivUnsArrByUns(pTemp->dc.sl, 10, 5); + pTemp->dc.id--; + } + + if (i==0) + _MacDCopy(pDst,pTemp); + + _MacRet(pDst); + +} diff --git a/gfm/demo01.c b/gfm/demo01.c new file mode 100755 index 000000000..f2358b154 --- /dev/null +++ b/gfm/demo01.c @@ -0,0 +1,26 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC da, *a=&da, db, *b=&db, dc, *c=&dc; + char str[30]; + + ZeroDecimal(a); + ZeroDecimal(b); + ZeroDecimal(c); + + printf(" First number: "); + scanf("%s", str); + ConvAsciiToDecimal(a,str); + + printf("Second number: "); + scanf("%s", str); + ConvAsciiToDecimal(b,str); + + MultiplyDecimalAndRound(c, a, b, 2); + + ConvDecimalToAscii(str,c); + printf("The product rounded to 2 decimal places is %s\n",str); +} diff --git a/gfm/demo02.c b/gfm/demo02.c new file mode 100755 index 000000000..7cf7c5e3e --- /dev/null +++ b/gfm/demo02.c @@ -0,0 +1,22 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC da, *a=&da, db, *b=&db, dc, *c=&dc; + + ZeroDecimal(a); + ZeroDecimal(b); + ZeroDecimal(c); + + printf(" First number: "); + dscanf("%t", a); + + printf("Second number: "); + dscanf("%t", b); + + MultiplyDecimalAndRound(c, a, b, 2); + + dprintf("The product rounded to 2 decimal places is %t\n",c); +} diff --git a/gfm/demo03.c b/gfm/demo03.c new file mode 100755 index 000000000..23a29f7b8 --- /dev/null +++ b/gfm/demo03.c @@ -0,0 +1,18 @@ +#include +#include "gm.h" +void main() +{ + DEC da, *a=&da, db, *b=&db; + DEC *f; + char s[30]; + + do { + printf("Type a number: "); + scanf("%s",s); + f = ConvAsciiToDecimal(a,s); + } while (f == GM_NULL); + + CopyDecimal(b,a); + ConvDecimalToAscii(s,b); + printf("You typed a %s\n",s); +} diff --git a/gfm/demo04.c b/gfm/demo04.c new file mode 100755 index 000000000..fce7071f4 --- /dev/null +++ b/gfm/demo04.c @@ -0,0 +1,23 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC da, *a=&da, db, *b=&db, dc, *c=&dc; + DEC dt, *t=&dt, dx, *x=&dx, *p; + char str[30]; + + ConvAsciiToDecimal(a, "13.22"); + ConvAsciiToDecimal(b, "34.89"); + ConvAsciiToDecimal(c, "1.0625"); + + p = MultiplyDecimalAndRound(x, c, AddDecimal(t, a, b), 2); + + if (p) { + ConvDecimalToAscii(str, x); + printf("The result is %s\n", str); + } + else + printf("The computation failed.\n"); +} diff --git a/gfm/demo05.c b/gfm/demo05.c new file mode 100755 index 000000000..95b44052f --- /dev/null +++ b/gfm/demo05.c @@ -0,0 +1,24 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC x[1]; + char s[30]; + + ConvAsciiToDecimal(x, "12,345.6"); + + ConvDecimalToAscii(s, x); + printf("ConvDecimalToAscii: %s\n", s); + ConvDecimalToAsciiRound(s, x, 2); + printf("ConvDecimalToAsciiRound: %s\n", s); + ConvDecimalToAsciiComma(s, x); + printf("ConvDecimalToAsciiComma: %s\n", s); + ConvDecimalToAsciiCommaRound(s, x, 2); + printf("ConvDecimalToAsciiCommaRound: %s\n", s); + ConvDecimalToScientific(s, x, -1); + printf("ConvDecimalToScientific: %s\n", s); + ConvDecimalToEngineering(s, x, -1); + printf("ConvDecimalToEngineering: %s\n", s); +} diff --git a/gfm/demo06.c b/gfm/demo06.c new file mode 100755 index 000000000..a3434e39f --- /dev/null +++ b/gfm/demo06.c @@ -0,0 +1,43 @@ +#include +#include "gm.h" +void printres(char *,DEC *); +void main(void); + +void main() +{ + DEC *x, *y, *p; + + x = AllocateDecimal(); + y = AllocateDecimal(); + + p = ConvAsciiToDecimal(x, "19.88"); + printres("x = ", p); + p = AbsoluteDecimal(y, x); + printres("abs(x) = ", p); + p = ChangeSignDecimal(y, x); + printres("-x = ", p); + p = FractionDecimal(y, x); + printres("fract(x) = ", p); + p = IntegerPartDecimal(y, x); + printres("int(x) = ", p); + p = SquareRootDecimal(y, x); + printres("sqrt(x) = ", p); + + FreeDecimal(x); + FreeDecimal(y); +} + +void printres(str, pd) +char *str; +DEC *pd; +{ + char sd[22]; + + printf("%12s", str); + if (pd) { + ConvDecimalToAscii(sd, pd); + printf("%s\n", sd); + } + else + printf("undefined\n"); +} diff --git a/gfm/demo07.c b/gfm/demo07.c new file mode 100755 index 000000000..e55b1e17e --- /dev/null +++ b/gfm/demo07.c @@ -0,0 +1,56 @@ +#include +#include "gm.h" +void printres(char *,DEC *); +void main(void); + +void main() +{ + DECP x, y, z; + DEC *p; + char s[40]; + + do { + printf(" First number (x) : "); + scanf("%s", s); + p = ConvAsciiToDecimal(x, s); + } while (!p); + do { + printf("Second number (y) : "); + scanf("%s", s); + p = ConvAsciiToDecimal(y, s); + } while (!p); + + printres("x = ", x); + printres("y = ", y); + p = AddDecimal(z, x, y); + printres("x + y = ", p); + p = SubtractDecimal(z, x, y); + printres("x - y = ", p); + p = MultiplyDecimal(z, x, y); + printres("x * y = ", p); + p = DivideDecimal(z, x, y); + printres("x / y = ", p); + p = MultiplyDecimalAndRound(z, x, y, 2); + printres("x * y (rounded) = ", p); + p = MultiplyDecimalAndTruncate(z, x, y, 2); + printres("x * y (truncated) = ", p); + p = DivideDecimalAndRound(z, x, y, 2); + printres("x / y (rounded) = ", p); + p = DivideDecimalAndTruncate(z, x, y, 2); + printres("x / y (truncated) = ", p); +} + +void printres(str, pd) +char *str; +DEC *pd; +{ + char sd[22]; + + printf("%20s", str); + if (pd) { + ConvDecimalToAscii(sd, pd); + printf("%s\n", sd); + } + else + printf("undefined\n"); +} diff --git a/gfm/demo08.c b/gfm/demo08.c new file mode 100755 index 000000000..b4eaae4e4 --- /dev/null +++ b/gfm/demo08.c @@ -0,0 +1,36 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC da, *a=&da, db, *b=&db; + DEC *f; + char s[30]; + int prec; + + do { + printf("Type a number: "); + scanf("%s",s); + f = ConvAsciiToDecimal(a,s); + } while (f == GM_NULL); + + printf("Round to how many decimal places? "); + scanf("%d", &prec); + + f = RoundDecimal(b, a, prec); + if (f) { + ConvDecimalToAscii(s, b); + printf(" Rounding yields %s\n", s); + } + else + printf("Rounding failed\n"); + + f = TruncateDecimal(b, a, prec); + if (f) { + ConvDecimalToAscii(s, b); + printf("Truncation yields %s\n", s); + } + else + printf("Truncating failed\n"); +} \ No newline at end of file diff --git a/gfm/demo09.c b/gfm/demo09.c new file mode 100755 index 000000000..01d3496bf --- /dev/null +++ b/gfm/demo09.c @@ -0,0 +1,26 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + char *path="tmpfile"; + char buffer[40]; + FILE *fil; + DEC da, *a=&da; + + ConvAsciiToDecimal(a, "3.14159"); + + dprintf(" dprintf outputs %t\n", a); + + dsprintf(buffer, "%t", a); + printf("dsprintf outputs %s\n", buffer); + + fil = fopen(path, "w"); + dfprintf(fil, "%t", a); + fclose(fil); + fil = fopen(path, "r"); + fscanf(fil, "%s", buffer); + fclose(fil); + printf("dfprintf outputs %s\n", buffer); +} diff --git a/gfm/demo10.c b/gfm/demo10.c new file mode 100755 index 000000000..afe49c16e --- /dev/null +++ b/gfm/demo10.c @@ -0,0 +1,11 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DECP x; + double f=98.76; + ConvDoubleToDecimalRound(x, f, 2); + dprintf("The double %7.2lf equals the DEC %t\n", f, x); +} \ No newline at end of file diff --git a/gfm/demo11.c b/gfm/demo11.c new file mode 100755 index 000000000..e2bad79ce --- /dev/null +++ b/gfm/demo11.c @@ -0,0 +1,16 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC da, *a=&da; + int i; + + do { + printf("Type a number: "); + i = dscanf("%t",a); + } while (i<1); + + dprintf("You typed a %t\n",a); +} diff --git a/gfm/demo12.c b/gfm/demo12.c new file mode 100755 index 000000000..fc349df71 --- /dev/null +++ b/gfm/demo12.c @@ -0,0 +1,44 @@ +#include +#include "gm.h" +void SmartScan(char *,DEC *); +void main(void); + +void main() +{ + DECP x; + + SmartScan("Type a number: ", x); + PrintDecimal("You typed a %t\n", x); +} + +void SmartScan(s, pd) +char *s; +DEC *pd; +{ + bool done; + int i; + + if (!pd) { + printf("Error: null DEC pointer\n"); + return; + } + + ClearMathError(); + done=FALSE; + while (!done) { + printf("%s",s); + ScanDecimal("%t",pd); + i = ReturnMathErrAndClear(); + if (i==GM_SUCCESS) + done=TRUE; + if (i==GM_CNVRW) { + done=TRUE; + printf("Warning: Digit loss due to rounding\n"); + } + if (i==GM_CNVRE) + printf("Error: Number out of range\n"); + if (i==GM_NAN) + printf("Error: Not a number\n"); + } + return; +} diff --git a/gfm/demo13.c b/gfm/demo13.c new file mode 100755 index 000000000..29132cbb4 --- /dev/null +++ b/gfm/demo13.c @@ -0,0 +1,34 @@ +#include +#include "gm.h" +void ErrorHandler(int,int); +void main(void); + +void ErrorHandler(code,ref) +int code,ref; +{ + char serr[15],sfun[32]; + ErrorName(serr, code); + FunctionName(sfun, ref); + printf("%s error in function %s\n",serr,sfun); +} + +void main() +{ + DEC da, *a=&da, db, *b=&db, dc, *c=&dc, *p; + + SetMathErrVector(ErrorHandler); + + ZeroDecimal(a); + ZeroDecimal(b); + ZeroDecimal(c); + + dprintf("First number: "); + dscanf("%.2t",a); + dprintf("Second number: "); + dscanf("%.2t",b); + p = DivideDecimalAndRound(c,a,b,2); + if (p) + dprintf("%t / %t = %t\n",a,b,c); + else + dprintf("Division failed.\n"); +} diff --git a/gfm/demo14.c b/gfm/demo14.c new file mode 100755 index 000000000..42d65eb92 --- /dev/null +++ b/gfm/demo14.c @@ -0,0 +1,18 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC *a[10]; + int i; + for (i=0; i<10; i++) + a[i] = AllocateDecimal(); + for (i=0; i<10; i++) + ConvIntToDecimal(a[i], i*i); + dprintf("%10s%10s\n","Element","Value"); + for (i=0; i<10; i++) + dprintf("%10d%10t\n", i, a[i]); + for (i=0; i<10; i++) + FreeDecimal(a[i]); +} diff --git a/gfm/demo15.c b/gfm/demo15.c new file mode 100755 index 000000000..77530d219 --- /dev/null +++ b/gfm/demo15.c @@ -0,0 +1,39 @@ +#include +#include "gm.h" +void main(void); + +void main() +{ + DEC *xarr[100], *yarr[100], *p; + DECP lina, linb, corr, gx, gy, px, py; + int n, i; + + printf("Number of elements: "); + scanf("%d", &n); + AllocateDecimalArray(xarr, n); + AllocateDecimalArray(yarr, n); + for (i=0; i +#include "gm.h" +void getdec(char *,DEC *); +void main(void); + +void main() +{ + int choice, opt, nper=0, diy=365; + DECP pv, intr, intamt; + DEC *p; + + printf("Simple interest computation\n"); + printf("Variable to solve for --\n"); + printf(" 1) Number of days\n 2) Interest rate\n"); + printf(" 3) Principal\n 4) Accrued interest\n"); + printf("Your choice: "); + scanf("%d", &choice); + if (choice == 1) + opt = GM_N; + if (choice == 2) + opt = GM_I; + if (choice == 3) + opt = GM_PV; + if (choice == 4) + opt = GM_INTR; + + if (opt != GM_N) { + printf("Number of days: "); + scanf("%d", &nper); + } + if (opt != GM_I) + getdec("Percentage annual interest rate: ", intr); + if (opt != GM_PV) + getdec("Principal: ", pv); + if (opt != GM_INTR) + getdec("Accrued interest: ", intamt); + dprintf("Number of days in year (360 or 365): "); + dscanf("%d", &diy); + + if (diy == 360) + p = simp360(&nper, intr, pv, intamt, opt); + else + p = simp365(&nper, intr, pv, intamt, opt); + + if (opt==GM_N) + dprintf("The result is %d\n",nper); + else { + if (p) + dprintf("The result is %v\n",p); + else + dprintf("Simple interest failed\n"); + } +} + +void getdec(str, x) +char *str; +DEC *x; +{ + int i; + + do { + printf("%s", str); + i = dscanf("%t", x); + } while (i<1); +} diff --git a/gfm/demo17.c b/gfm/demo17.c new file mode 100755 index 000000000..14ebc18cd --- /dev/null +++ b/gfm/demo17.c @@ -0,0 +1,44 @@ +#include +#include "gm.h" +void getdec(char *,DEC *); +void main(void); + +void main() +{ + int nper, nyear, opt, begend; + DECP pv, pmt, fv, intr, aintr; + DEC *p; + + printf("Monthly payment computation\n"); + + getdec("Purchase price: ", pv); + getdec("Percentage annual interest rate: ", aintr); + printf("Length of loan (years): "); + dscanf("%d", &nyear); + + nper = nyear * 12; + ZeroDecimal(fv); + DivideDecimalByInt(intr, aintr, 12); + opt = GM_PMT; + begend = GM_END; + + p = CompoundInterest(&nper, intr, pv, pmt, fv, begend, opt); + if (p) { + AbsoluteDecimal(pmt, pmt); + dprintf("The monthly payment is %v\n", pmt); + } + else + dprintf("CompoundInterest failed\n"); +} + +void getdec(str, x) +char *str; +DEC *x; +{ + int i; + + do { + printf("%s", str); + i = dscanf("%t", x); + } while (i<1); +} diff --git a/gfm/demo18.c b/gfm/demo18.c new file mode 100755 index 000000000..1d05cab93 --- /dev/null +++ b/gfm/demo18.c @@ -0,0 +1,53 @@ +#include +#include "gm.h" +void getdec(char *,DEC *); +void main(void); +static DEC *payintr[500], *payprin[500], *balance[500]; + +void main() +{ + int nper, nyear, begend, i; + DECP pv, pmt, intr, aintr; +extern DEC *payintr[500], *payprin[500], *balance[500]; + + printf("Amortization schedule\n"); + + getdec("Amount of loan (positive): ", pv); + getdec("Percentage annual interest rate: ", aintr); + printf("Length of loan (years): "); + dscanf("%d", &nyear); + getdec("Monthly payment (positive): ", pmt); + + nper = nyear * 12; + DivideDecimalByInt(intr, aintr, 12); + begend = GM_END; + + AllocateDecimalArray(payintr, nper+1); + AllocateDecimalArray(payprin, nper+1); + AllocateDecimalArray(balance, nper+1); + + AmortizeTable(payintr, payprin, balance, intr, + pv, pmt, begend, nper); + + printf("%15s%20s%20s%20s\n", "Payment #", "Interest", + "Principal", "Balance"); + for (i=1; i<=nper; i++) + dprintf("%15d%20v%20v%20v\n", i, payintr[i], + payprin[i], balance[i]); + + FreeDecimalArray(payintr); + FreeDecimalArray(payprin); + FreeDecimalArray(balance); +} + +void getdec(str, x) +char *str; +DEC *x; +{ + int i; + + do { + printf("%s", str); + i = dscanf("%t", x); + } while (i<1); +} diff --git a/gfm/demo19.c b/gfm/demo19.c new file mode 100755 index 000000000..aa75fda3e --- /dev/null +++ b/gfm/demo19.c @@ -0,0 +1,46 @@ +#include +#include "gm.h" +void getdec(char *,DEC *); +void main(void); + +void main() +{ + DEC book[1], salv[1], partial[1]; + DEC *depr[50], *remval[50]; + int life, i; + + printf("Sum of years digits depreciation\n"); + + getdec("Book value: ", book); + getdec("Salvage value: ", salv); + printf("Lifetime of asset (years): "); + dscanf("%d", &life); + + ZeroDecimal(partial); + + AllocateDecimalArray(depr, life+1); + AllocateDecimalArray(remval, life+1); + + DepreciateSumOfYearsTable(depr, remval, book, + salv, life, partial); + printf("%20s%20s%20s\n", "Year #", + "Depreciation", "Remaining Value"); + for (i=1; i<=life; i++) + dprintf("%20d%20v%20v\n", i, + depr[i], remval[i]); + + FreeDecimalArray(depr); + FreeDecimalArray(remval); +} + +void getdec(str, x) +char *str; +DEC *x; +{ + int i; + + do { + printf("%s", str); + i = dscanf("%t", x); + } while (i<1); +} diff --git a/gfm/dexp.c b/gfm/dexp.c new file mode 100755 index 000000000..f4daff912 --- /dev/null +++ b/gfm/dexp.c @@ -0,0 +1,77 @@ +/* DEC *AntiLogEDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = e^pSrc; + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy Aug 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *AntiLogEDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + int i; + DEC *pa; + + _MacStart(GM_DEXP); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + if((pSrc->dc.id == 0) && ((pSrc->dc.msd == 0) && + (pSrc->ls.lsl[1] == 0L) && (pSrc->dc.sl[1] == 0)) + && (!(pSrc->dc.sl[0] & 0x8000))) { + pa = &decE; /* points to constant 'e' */ + _MacDCopy(pDst,pa); + i = _IntPwrDec80Bit(pDst,pDst,ConvDecimalToInt(pSrc)); + if(i != GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + } + else { + i = _ExpDec80Bit(pDst, pSrc); + if (i == GM_OVERFLOW) { + _MacErr(i); + _MacRet(GM_NULL); + } + } + + /* reduce from 80-bit back to 64-bit */ + if(_Sq5UnsTo4Uns(pDst) != GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pDst)) { + _MacErr(GM_UNDERFLOW); + } + + _MacRet(pDst); +} diff --git a/gfm/dexx.c b/gfm/dexx.c new file mode 100755 index 000000000..d16b7304f --- /dev/null +++ b/gfm/dexx.c @@ -0,0 +1,113 @@ +/* int _ExpDec80Bit(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst, *pSrc; + * + * DESCRIPTION + * Calculates e^pSrc, stores result in pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * GM_SUCCESS if calculation is successful, + * otherwise the error code (which could be underflow) + * + * ALGORITHM + * pSrc = a * ln 2 + b |b| < (ln 2) / 2 + * e^pSrc = (2^a) * (e^b) + * Using the Taylor series, + * e^b = 1 + b + (b^2)/2! + (b^3)/3! + ... + * + * AUTHOR + * Jared Levy April 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _ExpDec80Bit(pDst,pSrc) +DEC *pDst, *pSrc; +{ + int a, i; + DEC da, dpow2, db, dt, dfact, dterm; + DEC *pow2, *b, *fact, *pt, *term; + + if (CompareDecimal(pSrc,&decMaxExp) == 1) { + return(GM_OVERFLOW); + } + + if (CompareDecimal(pSrc,&decMinExp) == -1) { + _MacDZero(pDst); + return(GM_UNDERFLOW); + } + + /* calculate a = pSrc * (1/(ln 2)) */ + (void) _MulDec80Bit(&da, pSrc, &decReciprocalOfLn2); + + (void) _ScaleDec80Bit(&da,&da,0); + a = ConvDecimalToInt(&da); + + /* calculate b = pSrc - a * ln 2 */ + b=&db; + if (a == 0) { + _MacDCopy(b,pSrc); + } + else { + (void) _MulDec80Bit(&dt, &da, &decLn2); + (void) _SubDec80Bit(b, pSrc, &dt); + } + + /* calculate pSrc = (2^a) * (e^b) */ + fact = &dfact; + pt = &decOne; + term = &dterm; + _MacDCopy(fact,pt); + _MacDCopy(pDst,pt); + _AddDec80Bit(pDst, pDst, b); + _MacDCopy(term, b); + + do { + /* calulate next term */ + fact->dc.sl[0]++; + (void) _MulDec80Bit(term, b, term); + (void) _DivRndDec80Bit(term, term, fact, 23); + /* add term to series */ + (void) _AddDec80Bit(pDst, pDst, term); + /* calc next factorial term in divisor */ + } while (!(_MacIsDecZ(term))); + + if (a>0) { + pow2 = &dpow2; +/* + * I used to use the _MacDZero statement here, but Lattice C 6.0 + * pointed out that it had a single redundant line in the + * macro, so I expanded it and remove the redundant line. + * _MacDZero(pow2); + */ + pow2->dc.attr=0; + pow2->ls.lsl[0]=0; + pow2->ls.lsl[1]=0; + pow2->dc.msd=0; + + pow2->dc.id = 0; + pow2->dc.sl[a/16] = 1 << (a % 16); + i =_MulDec80Bit(pDst, pDst, pow2); + return(i); + } + + while (a<0) { + _HalveUnsArr(pDst->dc.sl, 5); + a++; + } + + if (_MacIsDecZ(pDst)) + return(GM_UNDERFLOW); + + return(GM_SUCCESS); +} diff --git a/gfm/dfact.c b/gfm/dfact.c new file mode 100755 index 000000000..b54ad3b96 --- /dev/null +++ b/gfm/dfact.c @@ -0,0 +1,61 @@ +/* DEC *Factorial(pDst, n) + * + * ARGUMENT + * DEC *pDst; + * unsigned n; + * + * DESCRIPTION + * Sets pDst = n! + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, GM_NULL otherwise + * + * POSSIBLE ERRORS + * GM_NOMEMORY + * GM_OVERFLOW (if n > 20) + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *Factorial(pDst, n) +DEC *pDst; +unsigned n; +{ + DEC dmult, *mult = &dmult; + unsigned i; + + _MacStart(GM_DFACT); + + _MacOutVarD(pDst); + +/* check for overflow */ + if (n > 20) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + +/* do calculations */ + _MacDCopy(pDst, &decOne); + _MacDCopy(mult, &decOne); + + for (i=2; i<=n; i++) { + mult->dc.sl[0] = i; + _MulDec80Bit(pDst, pDst, mult); + } + +/* pDst fits into 64 bits */ + _MacRet(pDst); +} diff --git a/gfm/dfprintf.c b/gfm/dfprintf.c new file mode 100755 index 000000000..e704024c7 --- /dev/null +++ b/gfm/dfprintf.c @@ -0,0 +1,71 @@ +/* int FilePrintDecimal(stream, fmt, arg,) + * + * ARGUMENT + * FILE *stream; + * char *fmt; + * (?) arg; + * + * DESCRIPTION + * Prints out arguments, which may include DEC structures, to a file, + * according to the format string fmt. The function converts the DEC's + * to strings and calls fprintf. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The number of characters printed, the return from fprintf. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_INVALIDID + * GM_CNVRW + * GM_EOF + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int FilePrintDecimal(stream,fmt) +FILE *stream; +char *fmt; + +{ + char **outval, buffer[256]; + int i; + + _MacStart(GM_DFPRINTF); + + if (!fmt) { + _MacErr(GM_NULLPOINTER); + _MacRet(0); + } + + outval = &fmt; +/* print the output */ + dsprintf(buffer, fmt, + outval[1], outval[2], outval[3], outval[4], outval[5], + outval[6], outval[7], outval[8], outval[9], outval[10] +#ifndef _LDATA + ,outval[11], outval[12], outval[13], outval[14], outval[15], + outval[16], outval[17], outval[18], outval[19], outval[20] +#endif + ); + + i = fprintf(stream, "%s", buffer); + + if (i==EOF) + _MacErr(GM_EOF); + + _MacRet(i); +} diff --git a/gfm/dfract.c b/gfm/dfract.c new file mode 100755 index 000000000..c3f7d83fa --- /dev/null +++ b/gfm/dfract.c @@ -0,0 +1,45 @@ +/* DEC *FractionDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC* pDst ptr to the destination DEC structure. + * DEC* pSrc ptr to the source DEC structure. + * + * DESCRIPTION + * Sets pDst to the fractional part of pSrc. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to the DEC structure unless pSrc is null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 13-JAN-1987 17:20 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *FractionDecimal(pDst,pSrc) +DEC *pDst,*pSrc; +{ + DEC dtemp, *temp=&dtemp; + + _MacStart(GM_DFRACT); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + (void) _TruncateDec80Bit(temp, pSrc, 0); + (void) _SubDec80Bit(pDst, pSrc, temp); + + _MacRet(pDst); +} diff --git a/gfm/dfree.c b/gfm/dfree.c new file mode 100755 index 000000000..f9b9c1a7d --- /dev/null +++ b/gfm/dfree.c @@ -0,0 +1,54 @@ +/* void FreeDecimal(pSrc1) + * + * ARGUMENT + * pSrc1 is a ptr to the source DEC structure. + * + * DESCRIPTION + * Returns storage to DOS via free(). + * + * SIDE EFFECTS + * Does NOT CHECK to see if spaces was allocated via malloc(). + * Therefore, DOS will lock up cause cold reboot if unallocated + * space is freed + * + * RETURNS + * None. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 17-JAN-1987 14:35 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +void FreeDecimal(pSrc1) +DEC *pSrc1; +{ + _MacStart(GM_DFREE); +/* Can't free null pointers */ + if(!pSrc1) { + _MacErr(GM_NULLPOINTER); + _MacRetV; + } + +/* But we'll free him a DEC if possible */ +#ifdef LATTICE + free((char *) pSrc1); +#else + free((char *) pSrc1); +#endif + + _MacRetV; +} + diff --git a/gfm/dfscanf.c b/gfm/dfscanf.c new file mode 100755 index 000000000..740d10722 --- /dev/null +++ b/gfm/dfscanf.c @@ -0,0 +1,64 @@ +/* int FileScanDecimal(fFile, sFmt, arg,) + * + * ARGUMENT + * FILE *fFile; + * char *sFmt; + * (?) arg; + * + * DESCRIPTION + * Scans arguments, which may include DEC structures, + * from a string, according + * to the format string sFmt. The function converts the DEC's to strings + * and calls scanf. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The number of fields scanned, the return from scanf. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_INVALIDID + * GM_CNVRW + * GM_CNVRE + * GM_NAN + * GM_EOF + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int FileScanDecimal(fFile,sFmt) +FILE *fFile; +char *sFmt; + +{ + int i; + char **pOutVal; + + _MacStart(GM_DFSCANF); + + pOutVal=&sFmt; + i=_ScanfAux(3, (char *) fFile, sFmt, + pOutVal[1], pOutVal[2], pOutVal[3], pOutVal[4], pOutVal[5], + pOutVal[6], pOutVal[7], pOutVal[8], pOutVal[9], pOutVal[10] +#ifndef _LDATA + ,pOutVal[11], pOutVal[12], pOutVal[13], pOutVal[14], pOutVal[15], + pOutVal[16], pOutVal[17], pOutVal[18], pOutVal[19], pOutVal[20] +#endif + ); + + _MacRet(i); +} + diff --git a/gfm/dftod.c b/gfm/dftod.c new file mode 100755 index 000000000..657ae07d2 --- /dev/null +++ b/gfm/dftod.c @@ -0,0 +1,129 @@ +/* DEC *ConvDoubleToDecimal( x, f) + * + * ARGUMENT + * DEC *x; + * double f; + * + * DESCRIPTION + * Converts a double to a DEC with maximum implied decimal. Uses + * eTwoTo32 (2^32), eTwoTo63 (2^63), and ergGMPowersOfTenDouble + * (powers of ten), all global double variables. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NOMEMORY + * GM_CNVRE + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ConvDoubleToDecimal( x, f) +DEC *x; +double f; + +{ + int nid; + mbool wfIsNeg=FALSE; + double g; + + _MacStart(GM_DFTOD); + _MacOutVarD(x); + +/* take absolute value of negative values */ + if (f<0.0) { + wfIsNeg = TRUE; + f = -f; + } + +/* f = 0 */ + if (f == 0.0) { + _MacDZero(x); + _MacRet(x); + } + +/* overflow & underflow (MAXID = 18, MINID = 0) */ + if ((f>=eTwoTo63) || (f<.5e-18)) { + if (x) + _MacDZero(x); + _MacErr(GM_CNVRE); + _MacRet(GM_NULL); + } + +/* take absolute value of negative values */ + if (f<0.0) { + wfIsNeg = TRUE; + f = -f; + } + + _MacDZero(x); + +/* calculate implied decimal of DEC */ + g = eTwoTo63/f; + nid = 0; + while ((nid <= 17) && (ergGMPowersOfTenDouble[nid+1] <= g)) + nid++; + +/* adjust by power of 10 */ + f = f * ergGMPowersOfTenDouble[nid]; + +/* add .5 to round rather than truncate */ + f+= 0.5; + +/* change float to 64 bit integer */ + if (f >= eTwoTo32 - 1) { +#ifdef ZORTECH + if ( (f / eTwoTo32) > eTwoTo31 ) { + x->ls.lsl[1] = (unsigned long) ((f / eTwoTo32) - eTwoTo31 ); + x->ls.lsl[1] += (unsigned long) eTwoTo31; + } else + x->ls.lsl[1] = (unsigned long) (f / eTwoTo32); +#else + x->ls.lsl[1] = (unsigned long) (f / eTwoTo32); +#endif + g = (double) x->ls.lsl[1]; + f-= g * eTwoTo32; + while (f<0.0) { + x->ls.lsl[1]--; + f+= eTwoTo32; + } + while (f>= eTwoTo32) { + x->ls.lsl[1]++; + f-= eTwoTo32; + } + } + else + x->ls.lsl[1] = 0; + +#ifdef ZORTECH + if ( f > eTwoTo31 ) { + x->ls.lsl[0] = f - eTwoTo31; + x->ls.lsl[0] += (unsigned long) eTwoTo31; + } else + x->ls.lsl[0] = (unsigned long) f; +#else + x->ls.lsl[0] = (unsigned long) f; +#endif + x->ls.lid = nid; + x->dc.msd = 0; /* msd can't be set either */ + + if (wfIsNeg) { + _MacDChgs(x); + } + + _MacRet(x); +} diff --git a/gfm/dftodr.c b/gfm/dftodr.c new file mode 100755 index 000000000..5eb5a1d3c --- /dev/null +++ b/gfm/dftodr.c @@ -0,0 +1,123 @@ +/* DEC *ConvDoubleToDecimalRound( x, f, nid) + * + * ARGUMENT + * DEC *x; + * double f; + * int nid; + * + * DESCRIPTION + * Converts a double to a DEC with implied decimal nid. Uses + * eTwoTo32 (2^32), eTwoTo63 (2^63), and ergGMPowersOfTenDouble + * (powers of ten), all global double variables. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NOMEMORY + * GM_CNVRE + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ConvDoubleToDecimalRound( x, f, nid) +DEC *x; +double f; +int nid; + +{ + mbool wfIsNeg=FALSE; + double g; + + + _MacStart(GM_DFTODR); + if ((nid > GM_MAXID) || (nid < GM_MINID)) { + _MacErr(GM_INVALIDID); + _MacRet(GM_NULL); + } + + _MacOutVarD(x); + + /* f = 0 */ + if (f == 0.0) { + _MacDZero(x); + _MacRet(x); + } + +/* take absolute value of negative values */ + if (f<0.0) { + wfIsNeg = TRUE; + f = -f; + } + +/* adjust by power of 10 */ + if (nid > 0) { + f*= ergGMPowersOfTenDouble[nid]; + } + + _MacDZero(x); + +/* overflow and underflow */ + if ((f>=eTwoTo63) || (f<0.5)) { + _MacErr(GM_CNVRE); + _MacRet(GM_NULL); + } + +/* add .5 to round rather than truncate */ + f+= 0.5; + +/* change float to 64 bit integer */ + if (f >= eTwoTo32-1) { +#ifdef ZORTECH + if ( (f / eTwoTo32) > eTwoTo31 ) { + x->ls.lsl[1] = (unsigned long) ((f / eTwoTo32) - eTwoTo31 ); + x->ls.lsl[1] += (unsigned long) eTwoTo31; + } else + x->ls.lsl[1] = (unsigned long) (f / eTwoTo32); +#else + x->ls.lsl[1] = (unsigned long) (f / eTwoTo32); +#endif + g = (double) x->ls.lsl[1]; + if (g<0.0) + g+= eTwoTo32; + f = f - g * eTwoTo32; + while (f<0.0) { + x->ls.lsl[1]--; + f+= eTwoTo32; + } + while (f>= eTwoTo32) { + x->ls.lsl[1]++; + f-= eTwoTo32; + } + } +#ifdef ZORTECH + if ( f > eTwoTo31 ) { + x->ls.lsl[0] = f - eTwoTo31; + x->ls.lsl[0] += (unsigned long) eTwoTo31; + } else + x->ls.lsl[0] = (unsigned long) f; +#else + x->ls.lsl[0] = (unsigned long) f; +#endif + x->ls.lid = nid; + + if (wfIsNeg) + _MacDChgs(x); + + _MacRet(x); +} diff --git a/gfm/dint.c b/gfm/dint.c new file mode 100755 index 000000000..abf2d41d6 --- /dev/null +++ b/gfm/dint.c @@ -0,0 +1,44 @@ +/* DEC *IntegerPartDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC* pDst ptr to the destination DEC structure. + * DEC* pSrc ptr to the source DEC structure. + * + * DESCRIPTION + * Sets pDst to the integer part of pSrc. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to the DEC structure unless pSrc is null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * + * AUTHOR + * Andy Anderson 13-JAN-1987 17:20 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *IntegerPartDecimal(pDst,pSrc) +DEC *pDst,*pSrc; +{ + + _MacStart(GM_DINT); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + (void) _TruncateDec80Bit(pDst, pSrc, 0); + + _MacRet(pDst); +} diff --git a/gfm/diseq.c b/gfm/diseq.c new file mode 100755 index 000000000..dddb604a4 --- /dev/null +++ b/gfm/diseq.c @@ -0,0 +1,53 @@ +/* int IsDecimalEqual(pSrc1,pSrc2) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Compares pSrc1:pSrc2 and return TRUE if pSrc1==pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if scr1==scr2, FALSE if pSrc1 != pSrc2. + * However, returns GM_NULLPOINTER if pSrc1 or pSrc2 point to a null. + * + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 14-JAN-1987 14:27 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalEqual(pSrc1,pSrc2) +DEC *pSrc1,*pSrc2; +{ + + int i; + + _MacStart(GM_DISEQ); + + i=CompareDecimal(pSrc1,pSrc2); + switch(i) { + case 0: { + _MacRet(TRUE); + } + case 1: + case -1: { + _MacRet(FALSE); + } + } + _MacRet(i); +} diff --git a/gfm/disge.c b/gfm/disge.c new file mode 100755 index 000000000..899853b44 --- /dev/null +++ b/gfm/disge.c @@ -0,0 +1,52 @@ +/* int IsDecimalGreaterOrEqual(pSrc1,pSrc2) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Compares pSrc1:pSrc2 and return TRUE if pSrc1>=pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if scr1>=scr2, FALSE if pSrc1 < pSrc2. + * However, returns GM_NULLPOINTER if pSrc1 or pSrc2 point to a null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 14-JAN-1987 14:27 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalGreaterOrEqual(pSrc1,pSrc2) +DEC *pSrc1,*pSrc2; +{ + + int i; + + _MacStart(GM_DISGE); + + i=CompareDecimal(pSrc1,pSrc2); + switch(i) { + case 0: + case 1: { + _MacRet(TRUE); + } + case -1: { + _MacRet(FALSE); + } + } + _MacRet(i); +} diff --git a/gfm/disgt.c b/gfm/disgt.c new file mode 100755 index 000000000..735135c02 --- /dev/null +++ b/gfm/disgt.c @@ -0,0 +1,52 @@ +/* int IsDecimalGreater(pSrc1,pSrc2) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Compares pSrc1:pSrc2 and return TRUE if pSrc1>pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if scr1>scr2, FALSE if pSrc1 <= pSrc2. + * However, returns GM_NULLPOINTER if pSrc1 or pSrc2 point to a null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 22-APR-1987 14:27 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalGreater(pSrc1,pSrc2) +DEC *pSrc1,*pSrc2; +{ + int i; + + _MacStart(GM_DISGT); + + i=CompareDecimal(pSrc1,pSrc2); + + switch(i) { + case 1: { + _MacRet(TRUE); + } + case 0: + case -1: { + _MacRet(FALSE); + } + } + _MacRet(i); +} diff --git a/gfm/disint.c b/gfm/disint.c new file mode 100755 index 000000000..124dc1380 --- /dev/null +++ b/gfm/disint.c @@ -0,0 +1,47 @@ +/* int IsDecimalInt(pSrc); + * + * ARGUMENT + * DEC *pSrc; + * + * DESCRIPTION + * Determines whether or not a DEC represents an integer value + * or decimal value. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * TRUE if pSrc has implied decimal of zero, otherwise FALSE. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 12-Sep-87 1435 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalInt(pSrc) +DEC *pSrc; +{ + DEC dtemp, *temp=&dtemp; + + _MacStart(GM_DISINT); + if (!pSrc) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLPOINTER); + } + + (void) _TruncateDec80Bit(temp, pSrc, 0); + + _MacRet(CompareDecimal(temp, pSrc)==0); +} diff --git a/gfm/disle.c b/gfm/disle.c new file mode 100755 index 000000000..c209f8b0a --- /dev/null +++ b/gfm/disle.c @@ -0,0 +1,54 @@ +/* int IsDecimalLessOrEqual(pSrc1,pSrc2) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Compares pSrc1:pSrc2 and return TRUE if pSrc1<=pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if scr1<=scr2, FALSE if pSrc1 > pSrc2. + * However, returns GM_NULLPOINTER if pSrc1 or pSrc2 point to a null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * + * AUTHOR + * Andy Anderson 22-APR-1987 14:27 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalLessOrEqual(pSrc1,pSrc2) +DEC *pSrc1,*pSrc2; +{ + + int i; + + _MacStart(GM_DISLE); + + i=CompareDecimal(pSrc1,pSrc2); + + switch(i) { + case 0: + case -1: { + _MacRet(TRUE); + } + case 1: { + _MacRet(FALSE); + } + } + _MacRet(i); +} diff --git a/gfm/dislt.c b/gfm/dislt.c new file mode 100755 index 000000000..6183788a2 --- /dev/null +++ b/gfm/dislt.c @@ -0,0 +1,54 @@ +/* int IsDecimalLess(pSrc1,pSrc2) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Compares pSrc1:pSrc2 and return TRUE if pSrc1= pSrc2. + * However, returns GM_NULLPOINTER if pSrc1 or pSrc2 point to a null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 22-APR-1987 14:27 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalLess(pSrc1,pSrc2) +DEC *pSrc1,*pSrc2; +{ + + int i; + + _MacStart(GM_DISLT); + + i=CompareDecimal(pSrc1,pSrc2); + + switch(i) { + case -1: { + _MacRet(TRUE); + } + case 0: + case 1: { + _MacRet(FALSE); + } + } + + _MacRet(i); +} diff --git a/gfm/disne.c b/gfm/disne.c new file mode 100755 index 000000000..6bfc756fb --- /dev/null +++ b/gfm/disne.c @@ -0,0 +1,54 @@ +/* int IsDecimalNotEqual(pSrc1,pSrc2) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Compares pSrc1:pSrc2 and return TRUE if pSrc1!=pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if scr1!=scr2, FALSE if pSrc1 == pSrc2. + * However, returns GM_NULLPOINTER if pSrc1 or pSrc2 point to a null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 22-APR-1987 14:27 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalNotEqual(pSrc1,pSrc2) +DEC *pSrc1,*pSrc2; +{ + + int i; + + _MacStart(GM_DISNE); + + i=CompareDecimal(pSrc1,pSrc2); + + switch(i) { + case 1: + case -1: { + _MacRet(TRUE); + } + case 0: { + _MacRet(FALSE); + } + } + _MacRet(i); + +} diff --git a/gfm/disneg.c b/gfm/disneg.c new file mode 100755 index 000000000..63a6a266d --- /dev/null +++ b/gfm/disneg.c @@ -0,0 +1,44 @@ +/* int IsDecimalNegative(pSrc1); + * + * ARGUMENT + * DEC *pSrc1; + * + * DESCRIPTION + * Decides whether pSrc1 is a negative number. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if negative, else returns FALSE. Note that if a null + * pointer is handed us, we return GM_NULLPOINTER. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 15-JAN-1987 16:00 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalNegative(pSrc1) +DEC *pSrc1; +{ + + _MacStart(GM_DISNEG); + _MacInVarI(pSrc1); + + /* Then check for negative number */ + if(_MacIsDecN(pSrc1)) + {_MacRet(TRUE);} + else + _MacRet(FALSE); +} diff --git a/gfm/dispos.c b/gfm/dispos.c new file mode 100755 index 000000000..1220a7f49 --- /dev/null +++ b/gfm/dispos.c @@ -0,0 +1,44 @@ +/* int IsDecimalPositive(pSrc1); + * + * ARGUMENT + * DEC *pSrc1; + * + * DESCRIPTION + * Decides whether pSrc1 is a positive number. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if positive, else returns FALSE. Note that if a null + * pointer is handed us, we return GM_NULLPOINTER. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 15-JAN-1987 16:00 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalPositive(pSrc1) +DEC *pSrc1; +{ + + _MacStart(GM_DISPOS); + _MacInVarI(pSrc1); + + /* Then check for positive number */ + if(_MacIsDecP(pSrc1)) + {_MacRet(TRUE);} + else + _MacRet(FALSE); +} diff --git a/gfm/diszero.c b/gfm/diszero.c new file mode 100755 index 000000000..e811f7b02 --- /dev/null +++ b/gfm/diszero.c @@ -0,0 +1,44 @@ +/* int IsDecimalZero(pSrc1); + * + * ARGUMENT + * DEC *pSrc1; + * + * DESCRIPTION + * Decides whether pSrc1 is a zero. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns TRUE if zero, else returns FALSE. Note that if a null + * pointer is handed us, we return GM_NULLPOINTER. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 15-JAN-1987 16:00 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int IsDecimalZero(pSrc1) +DEC *pSrc1; +{ + + _MacStart(GM_DISZERO); + _MacInVarI(pSrc1); + + /* Then check for non-zero number */ + if(_MacIsDecZ(pSrc1)) + {_MacRet(TRUE);} + else + _MacRet(FALSE); +} diff --git a/gfm/divarr.c b/gfm/divarr.c new file mode 100755 index 000000000..77e295534 --- /dev/null +++ b/gfm/divarr.c @@ -0,0 +1,66 @@ +/* DEC **DivideDecimalArrays(pDst,pSrc1,pSrc2,n) + * + * ARGUMENT + * pDst is a ptr to the array of destination DEC pointers. + * pSrc1 and pSrc2 are ptrs to the arrays of source DEC pointers + * n is the number of elements in pSrc + * + * DESCRIPTION + * Sets pDst[i] = pSrc1[i] / pSrc2[i]. If pDst is null, tries to create a + * DEC structure, then divide. If some of the pSrc structures + * are null, the non-null ones are still divided. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to the new structure if successful, otherwise + * returns GM_NULLARR. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC **DivideDecimalArrays(pDst,pSrc1,pSrc2,n) +DEC **pDst; +DEC **pSrc1, **pSrc2; +int n; +{ + int i; + +/* source must be supplied !! */ + _MacStart(GM_DIVARR); + + if (!pSrc1 || !pSrc2 || !pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* Divide the numbers */ + for (i=0; i +#include "gm.h" +#include "gmsystem.h" + +DEC **DivideDecimalArrayByDecimal(pDst,pSrc1,pSrc2,n) +DEC **pDst; +DEC **pSrc1, *pSrc2; +int n; +{ + int i; + DEC dcop2, *cop2=&dcop2; + mbool copyback; + +/* source must be supplied !! */ + _MacStart(GM_DIVARRD); + + _MacInVar(pSrc2, GM_NULLARR); + if (!pSrc1 || !pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* if pSrc2 is 0, call error routine once */ + if (_MacIsDecZ(pSrc2)) { + _MacErr(GM_DIV0); + _MacRet(GM_NULLARR); + } + +/* Copy Src2 in case it is part of destination array */ + _MacDCopy(cop2, pSrc2); + +/* check if backwards copy is necessary */ + copyback=(pDst > pSrc1); + +/* Divide the numbers */ + i = copyback ? n-1 : 0; + while ((i=0)) { + (void) DivideDecimal(pDst[i], pSrc1[i], cop2); +/* DivideDecimal sets the error flag each time an error occurs */ + + if (copyback) + i--; + else + i++; + } + + + _MacRet(pDst); +} diff --git a/gfm/divdfd.c b/gfm/divdfd.c new file mode 100755 index 000000000..9e5869589 --- /dev/null +++ b/gfm/divdfd.c @@ -0,0 +1,58 @@ +/* DEC *DivideDecimalByDouble(pDst,pSrc1,l) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * l is the double to be divided into pSrc1 + * + * DESCRIPTION + * Divides pSrc1 by 'l' and puts the result in dest DEC structure. + * + * SIDE EFFECTS + * On overflow, the dest value is destroyed. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * GM_CNVRE + * + * AUTHOR + * Andy Anderson 08-JUL-1987 1500 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DivideDecimalByDouble(pDst,pSrc1,l) +DEC *pDst,*pSrc1; +double l; +{ + DEC decS2, *pSrc2=&decS2, *pd; + + _MacStart(GM_DIVDFD); + + /* Convert the double to a DEC */ + pSrc2=ConvDoubleToDecimal(pSrc2,l); + if (!pSrc2) { + if (pDst) + _MacDZero(pDst); + _MacRet(GM_NULL); + } + + pd = DivideDecimal(pDst,pSrc1,pSrc2); + + _MacRet(pd); +} diff --git a/gfm/divid.c b/gfm/divid.c new file mode 100755 index 000000000..559a8c2f8 --- /dev/null +++ b/gfm/divid.c @@ -0,0 +1,51 @@ +/* DEC *DivideDecimalByInt(pDst,pSrc1,lSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * int lSrc2; + * + * DESCRIPTION + * Divides pSrc1 by ConvIntToDecimal(lSrc2) and puts the result in + * pDst. pSrc1 and lSrc2 remain unchanged. Note that + * we always call the _DivDec80Bit() routine to do the actual divide, + * sign chking, etc. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_NOMEMORY, GM_DIV0) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 5-Mar-87 17:45 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC* DivideDecimalByInt(pDst,pSrc1,lSrc2) +DEC *pDst,*pSrc1; +int lSrc2; +{ + + DEC *t; + + _MacStart(GM_DIVID); + + t = DivideDecimalByLong(pDst,pSrc1,(long) lSrc2); + _MacRet(t); +} diff --git a/gfm/divld.c b/gfm/divld.c new file mode 100755 index 000000000..2ce1a728b --- /dev/null +++ b/gfm/divld.c @@ -0,0 +1,60 @@ +/* DEC *DivideDecimalByLong(pDst,pSrc1,lSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * long lSrc2; + * + * DESCRIPTION + * Divides pSrc1 by ConvLongToDecimal(lSrc2) and puts the result in + * pDst. + * + * SIDE EFFECTS + * None + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_NOMEMORY, GM_DIV0) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 5-Mar-87 17:45 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC* DivideDecimalByLong(pDst,pSrc1,lSrc2) +DEC *pDst,*pSrc1; +long lSrc2; +{ + + DEC temp1,*tp1,*pd; + + _MacStart(GM_DIVLD); + _MacInVar(pSrc1,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + /* init default pointer */ + tp1=&temp1; + + /* convert the long first, then call the divide routine */ + tp1=ConvLongToDecimal(tp1,lSrc2); + + pd = DivideDecimal(pDst,pSrc1,tp1); + + /* the divide routine already set any errors */ + _MacRet(pd); + +} diff --git a/gfm/divstr.c b/gfm/divstr.c new file mode 100755 index 000000000..97b85538a --- /dev/null +++ b/gfm/divstr.c @@ -0,0 +1,68 @@ +/* DEC DivideAscii(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * pDst is a poiter to the destination DEC structure + * pSrc1 is a pointer to source1 ASCII string + * pSrc2 is a pointer to source2 ASCII string + * + * DESCRIPTION + * Divides ConvAsciiToDecimal(pSrc1)/ConvAsciiToDecimal(pSrc2) + * = pDst DEC structure. + * + * SIDE EFFECTS + * On error, the value of the dest structure is undetermined. + * + * RETURNS + * Returns a pointer to the dest structure on success, + * otherwise returns a GM_NULL(a C false). On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLSTRING + * GM_CNVRE + * GM_CNVRW + * GM_NAN + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 20-Feb-87 17:40 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DivideAscii(pDst,pSrc1,pSrc2) +DEC *pDst; +char *pSrc1,*pSrc2; +{ + + DEC tp1,tp2; + DEC *ps1,*ps2,*pd; + + _MacStart(GM_DIVSTR); + _MacOutVar(pDst,GM_NULL); + ps1=&tp1; + ps2=&tp2; + + /* convert ascii arguments to DEC */ + ps1=ConvAsciiToDecimal(ps1,pSrc1); + if (!ps1) + _MacRet(GM_NULL); + + ps2=ConvAsciiToDecimal(ps2,pSrc2); + if (!ps2) + _MacRet(GM_NULL); + + /* then do the divide */ + pd = DivideDecimal(pDst,ps1,ps2); + + _MacRet(pd); +} diff --git a/gfm/divuid.c b/gfm/divuid.c new file mode 100755 index 000000000..cda7f43a9 --- /dev/null +++ b/gfm/divuid.c @@ -0,0 +1,51 @@ +/* DEC *DivideDecimalByUns(pDst,pSrc1,lSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * unsigned lSrc2; + * + * DESCRIPTION + * Divides pSrc1 by ConvIntToDecimal(lSrc2) and puts the result in + * pDst. pSrc1 and lSrc2 remain unchanged. Note that + * we always call the _DivDec80Bit() routine to do the actual divide, + * sign chking, etc. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_NOMEMORY, GM_DIV0) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 5-Mar-87 17:45 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DivideDecimalByUns(pDst,pSrc1,lSrc2) +DEC *pDst,*pSrc1; +unsigned int lSrc2; +{ + + DEC *t; + + _MacStart(GM_DIVUID); + + t = DivideDecimalByLong(pDst,pSrc1,(long) lSrc2); + _MacRet(t); +} diff --git a/gfm/divuld.c b/gfm/divuld.c new file mode 100755 index 000000000..ff11d50a9 --- /dev/null +++ b/gfm/divuld.c @@ -0,0 +1,54 @@ +/* DEC *DivideDecimalByUnsLong(pDst,pSrc1,ulSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * unsigned long ulSrc2; + * + * DESCRIPTION + * Divides pSrc1 by ultod(ulSrc2) & puts it into pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 5-Mar-87 18:15 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC* DivideDecimalByUnsLong(pDst,pSrc1,ulSrc2) +DEC *pDst,*pSrc1; +unsigned long ulSrc2; +{ + DEC temp1,*tp1,*pd; + + _MacStart(GM_DIVULD); + + /* init default pointer */ + tp1=&temp1; + + /* convert the unsigned long first, then call the divide routine */ + (void) ConvUnsLongToDecimal(tp1,ulSrc2); + + pd = DivideDecimal(pDst,pSrc1,tp1); + + _MacRet(pd); +} diff --git a/gfm/dllgfm.c b/gfm/dllgfm.c new file mode 100755 index 000000000..c92b2be1a --- /dev/null +++ b/gfm/dllgfm.c @@ -0,0 +1,13 @@ +#include + +int FAR PASCAL WEP(int p) +{ + int ok = 0; + switch(p) + { + case WEP_SYSTEM_EXIT: + case WEP_FREE_DLL: + default: ok = 1; break; + } + return ok; +} diff --git a/gfm/dllgfm.def b/gfm/dllgfm.def new file mode 100755 index 000000000..ad564617e --- /dev/null +++ b/gfm/dllgfm.def @@ -0,0 +1,52 @@ +LIBRARY DLLGFM +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE +HEAPSIZE 1024 +EXPORTS + WEP @1 RESIDENTNAME + _AbsoluteDecimal + _AddDecimal + _AddDoubleToDecimal + _AddIntToDecimal + _AntiLog10Decimal + _AntiLogEDecimal + _ChangeSignDecimal + _ConvAsciiToDecimal + _ConvDecimalToAscii + _ConvDecimalToDouble + _ConvDecimalToInt + _ConvDoubleToDecimalRound + _CopyDecimal + _CosineDecimal + _DecimalModuloLong + _DecimalPrecision + _DeleteTrailingZeroes + _DivideDecimal + _DivideDecimalByDouble + _ErrorName + _IntegerPartDecimal + _IsDecimalEqual + _IsDecimalGreater + _IsDecimalGreaterOrEqual + _IsDecimalLess + _IsDecimalLessOrEqual + _IsDecimalZero + _Log10Decimal + _LogEDecimal + _MaximumDecimal + _MinimumDecimal + _MultiplyDecimal + _MultiplyDecimalByDouble + _PowerDecimal + _ReturnMathErrAndClear + _RoundDecimal + _SineDecimal + _SquareRootDecimal + _StringPrintDecimal + _SubtractDecimal + _SwapDecimal + _TangentDecimal + _TestSignDecimal + _TruncateDecimal + _ZeroDecimal diff --git a/gfm/dllgfm.mak b/gfm/dllgfm.mak new file mode 100755 index 000000000..553fd1117 --- /dev/null +++ b/gfm/dllgfm.mak @@ -0,0 +1,3472 @@ +# Microsoft Visual C++ generated build script - Do not modify + +PROJ = DLLGFM +DEBUG = 0 +PROGTYPE = 1 +CALLER = +ARGS = +DLLS = +D_RCDEFINES = -d_DEBUG +R_RCDEFINES = -dNDEBUG +ORIGIN = MSVC +ORIGIN_VER = 1.00 +PROJPATH = C:\P.DUE\GFM\ +USEMFC = 0 +CC = cl +CPP = cl +CXX = cl +CCREATEPCHFLAG = +CPPCREATEPCHFLAG = +CUSEPCHFLAG = +CPPUSEPCHFLAG = +FIRSTC = ADATE360.C +FIRSTCPP = +RC = rc +CFLAGS_D_WDLL = /nologo /G2 /W3 /Zi /ALw /YX /Od /D "_DEBUG" /D "DOS" /Fr /GD /Fd"DLLGFM.PDB" /Fp"DLLGFM.PCH" +CFLAGS_R_WDLL = /nologo /Gs /G2 /W3 /Gf /ALw /YX /Od /D "NDEBUG" /D "DOS" /Fr /GD /GEf /GEe /Fp"DLLGFM.PCH" +LFLAGS_D_WDLL = /NOLOGO /NOD /NOE /PACKC:61440 /SEG:512 /ALIGN:16 /ONERROR:NOEXE /CO /MAP:FULL +LFLAGS_R_WDLL = /NOLOGO /NOD /NOE /PACKC:61440 /SEG:512 /ALIGN:16 /ONERROR:NOEXE /MAP:FULL +LIBS_D_WDLL = oldnames libw ldllcew commdlg.lib olecli.lib olesvr.lib shell.lib +LIBS_R_WDLL = oldnames libw ldllcew +RCFLAGS = /nologo +RESFLAGS = /nologo +RUNFLAGS = +DEFFILE = DLLGFM.DEF +OBJS_EXT = +LIBS_EXT = +!if "$(DEBUG)" == "1" +CFLAGS = $(CFLAGS_D_WDLL) +LFLAGS = $(LFLAGS_D_WDLL) +LIBS = $(LIBS_D_WDLL) +MAPFILE = nul +RCDEFINES = $(D_RCDEFINES) +!else +CFLAGS = $(CFLAGS_R_WDLL) +LFLAGS = $(LFLAGS_R_WDLL) +LIBS = $(LIBS_R_WDLL) +MAPFILE = nul +RCDEFINES = $(R_RCDEFINES) +!endif +!if [if exist MSVC.BND del MSVC.BND] +!endif +SBRS = ADATE360.SBR \ + ADATE365.SBR \ + ADATENLY.SBR \ + ADDARR.SBR \ + ADDARRD.SBR \ + ADDDFD.SBR \ + ADDID.SBR \ + ADDLD.SBR \ + ADDSTR.SBR \ + ADDUID.SBR \ + ADDULD.SBR \ + ADVPMT.SBR \ + AGMN.SBR \ + AMORT.SBR \ + AMORTTBL.SBR \ + ATOD.SBR \ + ATODR.SBR \ + BONDPRC.SBR \ + BONDYLD.SBR \ + COMP.SBR \ + COMPAUX.SBR \ + COMPCOMP.SBR \ + COMPSIMP.SBR \ + DABS.SBR \ + DACOS.SBR \ + DADD.SBR \ + DADX.SBR \ + DALLOC.SBR \ + DALOG.SBR \ + DARALLOC.SBR \ + DARCPY.SBR \ + DARFREE.SBR \ + DASIN.SBR \ + DATAN.SBR \ + DATAX.SBR \ + DBD360.SBR \ + DBD365.SBR \ + DBDNLY.SBR \ + DCHGS.SBR \ + DCHIX.SBR \ + DCMP.SBR \ + DCOS.SBR \ + DCOSS.SBR \ + DCOT.SBR \ + DCOX.SBR \ + DCPY.SBR \ + DCTOD.SBR \ + DDEG.SBR \ + DDIV.SBR \ + DDIVPF.SBR \ + DDIVPR.SBR \ + DDIVPT.SBR \ + DDIVR.SBR \ + DDIVT.SBR \ + DDIX.SBR \ + DDIXF.SBR \ + DDIXR.SBR \ + DDIXT.SBR \ + DELTRZ.SBR \ + DEXP.SBR \ + DEXX.SBR \ + DFACT.SBR \ + DFPRINTF.SBR \ + DFRACT.SBR \ + DFREE.SBR \ + DFTOD.SBR \ + DFTODR.SBR \ + DINT.SBR \ + DISEQ.SBR \ + DISGE.SBR \ + DISGT.SBR \ + DISINT.SBR \ + DISLE.SBR \ + DISLT.SBR \ + DISNE.SBR \ + DISNEG.SBR \ + DISPOS.SBR \ + DISZERO.SBR \ + DIVARR.SBR \ + DIVARRD.SBR \ + DIVDFD.SBR \ + DIVID.SBR \ + DIVLD.SBR \ + DIVSTR.SBR \ + DIVUID.SBR \ + DIVULD.SBR \ + DLN.SBR \ + DLNX.SBR \ + DLOG.SBR \ + DMAG.SBR \ + DMANT.SBR \ + DMAX.SBR \ + DMBYN.SBR \ + DMBYP10.SBR \ + DMBYP10T.SBR \ + DMEAN.SBR \ + DMI.SBR \ + DMIN.SBR \ + DMOD.SBR \ + DMODDF.SBR \ + DMODI.SBR \ + DMODL.SBR \ + DMODUI.SBR \ + DMODUL.SBR \ + DMUL.SBR \ + DMULR.SBR \ + DMULT.SBR \ + DMUX.SBR \ + DPCT.SBR \ + DPDB.SBR \ + DPDBTBL.SBR \ + DPDDB.SBR \ + DPDDBTBL.SBR \ + DPOW.SBR \ + DPOWI.SBR \ + DPOWRAT.SBR \ + DPOXI.SBR \ + DPREC.SBR \ + DPSL.SBR \ + DPSLTBL.SBR \ + DPSOY.SBR \ + DPSOYTBL.SBR \ + DRAD.SBR \ + DROOT.SBR \ + DROOTI.SBR \ + DROUND.SBR \ + DSETERTN.SBR \ + DSIGN.SBR \ + DSIN.SBR \ + DSINS.SBR \ + DSORT.SBR \ + DSPRINTF.SBR \ + DSQRT.SBR \ + DSQX.SBR \ + DSUB.SBR \ + DSUX.SBR \ + DSWAP.SBR \ + DTAN.SBR \ + DTOA.SBR \ + DTOAC.SBR \ + DTOACR.SBR \ + DTOAF.SBR \ + DTOAR.SBR \ + DTODC.SBR \ + DTODF.SBR \ + DTOENG.SBR \ + DTOFR.SBR \ + DTOI.SBR \ + DTOL.SBR \ + DTOSCI.SBR \ + DTOUI.SBR \ + DTOUL.SBR \ + DTRUNC.SBR \ + DTRUX.SBR \ + DZERO.SBR \ + DZEROARR.SBR \ + EFFTONOM.SBR \ + ERRNAME.SBR \ + FRTOD.SBR \ + FUNNAME.SBR \ + GCMP.SBR \ + GINC.SBR \ + GMEC.SBR \ + GMEF.SBR \ + GMGLOBAL.SBR \ + D10BY5.SBR \ + D10BY5T.SBR \ + GMRS.SBR \ + GMSERRI.SBR \ + HMI.SBR \ + INTRAUX.SBR \ + IRR.SBR \ + ITOD.SBR \ + LINEST.SBR \ + LOOKARR.SBR \ + LTOD.SBR \ + MAKID.SBR \ + MAKLD.SBR \ + MAKUID.SBR \ + MAKULD.SBR \ + MAXARR.SBR \ + MEDIAN.SBR \ + MGMN.SBR \ + MINARR.SBR \ + MIRR.SBR \ + MLI.SBR \ + MUL10.SBR \ + MUL10AD.SBR \ + MUL10L.SBR \ + MULARR.SBR \ + MULARRD.SBR \ + MULDFD.SBR \ + MULID.SBR \ + MULLD.SBR \ + MULSTR.SBR \ + MULUID.SBR \ + MULULD.SBR \ + NFV.SBR \ + NOMTOEFF.SBR \ + NPV.SBR \ + PADD.SBR \ + PCHANGE.SBR \ + PDIV.SBR \ + PMUL.SBR \ + POF.SBR \ + PREDX.SBR \ + PREDY.SBR \ + PSUB.SBR \ + PTOY.SBR \ + ROUNDCNT.SBR \ + SGMN.SBR \ + SIMP360.SBR \ + SIMP365.SBR \ + SIMPAUX.SBR \ + SMI.SBR \ + SPFV.SBR \ + SPPV.SBR \ + SQ5TO4.SBR \ + STNDDEV.SBR \ + SUBARR.SBR \ + SUBARRD.SBR \ + SUBDFD.SBR \ + SUBID.SBR \ + SUBLD.SBR \ + SUBSTR.SBR \ + SUBUID.SBR \ + SUBULD.SBR \ + SUMARR.SBR \ + SUMARRN.SBR \ + SUMARRP.SBR \ + TRUNCCNT.SBR \ + UITOD.SBR \ + ULTOD.SBR \ + USFV.SBR \ + USPV.SBR \ + WMEAN.SBR \ + YTOP.SBR \ + DLLGFM.SBR \ + DMBY1.SBR \ + DMBY1R.SBR + + +ADATE360_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADATE365_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADATENLY_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDARRD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDDFD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDLD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDSTR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDUID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADDULD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ADVPMT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +AGMN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +AMORT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +AMORTTBL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ATOD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ATODR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +BONDPRC_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +BONDYLD_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +COMP_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +COMPAUX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +COMPCOMP_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +COMPSIMP_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DABS_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DACOS_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DADD_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DADX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DALLOC_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DALOG_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DARALLOC_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DARCPY_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DARFREE_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DASIN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DATAN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DATAX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DBD360_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DBD365_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DBDNLY_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DCHGS_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCHIX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCMP_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCOS_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCOSS_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCOT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCOX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCPY_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DCTOD_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DDEG_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DDIV_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DDIVPF_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIVPR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIVPT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIVR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIVT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIXF_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIXR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DDIXT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DELTRZ_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DEXP_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DEXX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DFACT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DFPRINTF_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DFRACT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DFREE_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DFTOD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DFTODR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DINT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISEQ_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISGE_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISGT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISINT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISLE_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISLT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISNE_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISNEG_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISPOS_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DISZERO_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVARRD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVDFD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVLD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVSTR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVUID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DIVULD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DLN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DLNX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DLOG_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMAG_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMANT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMAX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMBYN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMBYP10_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMBYP10T_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMEAN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMIN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMOD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMODDF_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMODI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMODL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMODUI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMODUL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMUL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMULR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMULT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMUX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPCT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPDB_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPDBTBL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPDDB_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPDDBTBL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPOW_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPOWI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPOWRAT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPOXI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPREC_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPSL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPSLTBL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPSOY_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DPSOYTBL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DRAD_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DROOT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DROOTI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DROUND_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSETERTN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSIGN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSIN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSINS_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSORT_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DSPRINTF_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DSQRT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSQX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSUB_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DSUX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DSWAP_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTAN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DTOA_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTOAC_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTOACR_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTOAF_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTOAR_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTODC_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTODF_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DTOENG_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTOFR_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTOI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DTOL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DTOSCI_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DTOUI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DTOUL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DTRUNC_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DTRUX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DZERO_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DZEROARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +EFFTONOM_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +ERRNAME_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +FRTOD_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +FUNNAME_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h \ + f:\mathlib\gmfname.h + + +GCMP_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +GINC_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +GMEC_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +GMEF_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +GMGLOBAL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +D10BY5_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +D10BY5T_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +GMRS_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +GMSERRI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +HMI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +INTRAUX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +IRR_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +ITOD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +LINEST_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +LOOKARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +LTOD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MAKID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MAKLD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MAKUID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MAKULD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MAXARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MEDIAN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MGMN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MINARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MIRR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MLI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MUL10_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MUL10AD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MUL10L_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULARRD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULDFD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULLD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULSTR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULUID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +MULULD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +NFV_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +NOMTOEFF_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +NPV_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PADD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PCHANGE_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PDIV_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PMUL_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +POF_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PREDX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PREDY_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PSUB_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +PTOY_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +ROUNDCNT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SGMN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SIMP360_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +SIMP365_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +SIMPAUX_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SMI_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SPFV_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +SPPV_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +SQ5TO4_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +STNDDEV_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBARRD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBDFD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBLD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBSTR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBUID_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUBULD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUMARR_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUMARRN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +SUMARRP_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +TRUNCCNT_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +UITOD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +ULTOD_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +USFV_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +USPV_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +WMEAN_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +YTOP_DEP = f:\mathlib\gmsystem.h \ + f:\mathlib\gm.h + + +DLLGFM_DEP = + +DMBY1_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +DMBY1R_DEP = f:\mathlib\gm.h \ + f:\mathlib\gmsys1.h \ + f:\mathlib\gf.h \ + f:\mathlib\gmfncnum.h \ + f:\mathlib\gfd.h \ + f:\mathlib\gmfequs.h \ + f:\mathlib\gmfuncts.h \ + f:\mathlib\gmsystem.h + + +all: $(PROJ).DLL $(PROJ).BSC + +ADATE360.OBJ: F:\MATHLIB\ADATE360.C $(ADATE360_DEP) + $(CC) $(CFLAGS) $(CCREATEPCHFLAG) /c F:\MATHLIB\ADATE360.C + +ADATE365.OBJ: F:\MATHLIB\ADATE365.C $(ADATE365_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADATE365.C + +ADATENLY.OBJ: F:\MATHLIB\ADATENLY.C $(ADATENLY_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADATENLY.C + +ADDARR.OBJ: F:\MATHLIB\ADDARR.C $(ADDARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDARR.C + +ADDARRD.OBJ: F:\MATHLIB\ADDARRD.C $(ADDARRD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDARRD.C + +ADDDFD.OBJ: F:\MATHLIB\ADDDFD.C $(ADDDFD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDDFD.C + +ADDID.OBJ: F:\MATHLIB\ADDID.C $(ADDID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDID.C + +ADDLD.OBJ: F:\MATHLIB\ADDLD.C $(ADDLD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDLD.C + +ADDSTR.OBJ: F:\MATHLIB\ADDSTR.C $(ADDSTR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDSTR.C + +ADDUID.OBJ: F:\MATHLIB\ADDUID.C $(ADDUID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDUID.C + +ADDULD.OBJ: F:\MATHLIB\ADDULD.C $(ADDULD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADDULD.C + +ADVPMT.OBJ: F:\MATHLIB\ADVPMT.C $(ADVPMT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ADVPMT.C + +AGMN.OBJ: F:\MATHLIB\AGMN.C $(AGMN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\AGMN.C + +AMORT.OBJ: F:\MATHLIB\AMORT.C $(AMORT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\AMORT.C + +AMORTTBL.OBJ: F:\MATHLIB\AMORTTBL.C $(AMORTTBL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\AMORTTBL.C + +ATOD.OBJ: F:\MATHLIB\ATOD.C $(ATOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ATOD.C + +ATODR.OBJ: F:\MATHLIB\ATODR.C $(ATODR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ATODR.C + +BONDPRC.OBJ: F:\MATHLIB\BONDPRC.C $(BONDPRC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\BONDPRC.C + +BONDYLD.OBJ: F:\MATHLIB\BONDYLD.C $(BONDYLD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\BONDYLD.C + +COMP.OBJ: F:\MATHLIB\COMP.C $(COMP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\COMP.C + +COMPAUX.OBJ: F:\MATHLIB\COMPAUX.C $(COMPAUX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\COMPAUX.C + +COMPCOMP.OBJ: F:\MATHLIB\COMPCOMP.C $(COMPCOMP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\COMPCOMP.C + +COMPSIMP.OBJ: F:\MATHLIB\COMPSIMP.C $(COMPSIMP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\COMPSIMP.C + +DABS.OBJ: F:\MATHLIB\DABS.C $(DABS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DABS.C + +DACOS.OBJ: F:\MATHLIB\DACOS.C $(DACOS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DACOS.C + +DADD.OBJ: F:\MATHLIB\DADD.C $(DADD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DADD.C + +DADX.OBJ: F:\MATHLIB\DADX.C $(DADX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DADX.C + +DALLOC.OBJ: F:\MATHLIB\DALLOC.C $(DALLOC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DALLOC.C + +DALOG.OBJ: F:\MATHLIB\DALOG.C $(DALOG_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DALOG.C + +DARALLOC.OBJ: F:\MATHLIB\DARALLOC.C $(DARALLOC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DARALLOC.C + +DARCPY.OBJ: F:\MATHLIB\DARCPY.C $(DARCPY_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DARCPY.C + +DARFREE.OBJ: F:\MATHLIB\DARFREE.C $(DARFREE_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DARFREE.C + +DASIN.OBJ: F:\MATHLIB\DASIN.C $(DASIN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DASIN.C + +DATAN.OBJ: F:\MATHLIB\DATAN.C $(DATAN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DATAN.C + +DATAX.OBJ: F:\MATHLIB\DATAX.C $(DATAX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DATAX.C + +DBD360.OBJ: F:\MATHLIB\DBD360.C $(DBD360_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DBD360.C + +DBD365.OBJ: F:\MATHLIB\DBD365.C $(DBD365_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DBD365.C + +DBDNLY.OBJ: F:\MATHLIB\DBDNLY.C $(DBDNLY_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DBDNLY.C + +DCHGS.OBJ: F:\MATHLIB\DCHGS.C $(DCHGS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCHGS.C + +DCHIX.OBJ: F:\MATHLIB\DCHIX.C $(DCHIX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCHIX.C + +DCMP.OBJ: F:\MATHLIB\DCMP.C $(DCMP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCMP.C + +DCOS.OBJ: F:\MATHLIB\DCOS.C $(DCOS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCOS.C + +DCOSS.OBJ: F:\MATHLIB\DCOSS.C $(DCOSS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCOSS.C + +DCOT.OBJ: F:\MATHLIB\DCOT.C $(DCOT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCOT.C + +DCOX.OBJ: F:\MATHLIB\DCOX.C $(DCOX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCOX.C + +DCPY.OBJ: F:\MATHLIB\DCPY.C $(DCPY_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCPY.C + +DCTOD.OBJ: F:\MATHLIB\DCTOD.C $(DCTOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DCTOD.C + +DDEG.OBJ: F:\MATHLIB\DDEG.C $(DDEG_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDEG.C + +DDIV.OBJ: F:\MATHLIB\DDIV.C $(DDIV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIV.C + +DDIVPF.OBJ: F:\MATHLIB\DDIVPF.C $(DDIVPF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIVPF.C + +DDIVPR.OBJ: F:\MATHLIB\DDIVPR.C $(DDIVPR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIVPR.C + +DDIVPT.OBJ: F:\MATHLIB\DDIVPT.C $(DDIVPT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIVPT.C + +DDIVR.OBJ: F:\MATHLIB\DDIVR.C $(DDIVR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIVR.C + +DDIVT.OBJ: F:\MATHLIB\DDIVT.C $(DDIVT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIVT.C + +DDIX.OBJ: F:\MATHLIB\DDIX.C $(DDIX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIX.C + +DDIXF.OBJ: F:\MATHLIB\DDIXF.C $(DDIXF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIXF.C + +DDIXR.OBJ: F:\MATHLIB\DDIXR.C $(DDIXR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIXR.C + +DDIXT.OBJ: F:\MATHLIB\DDIXT.C $(DDIXT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DDIXT.C + +DELTRZ.OBJ: F:\MATHLIB\DELTRZ.C $(DELTRZ_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DELTRZ.C + +DEXP.OBJ: F:\MATHLIB\DEXP.C $(DEXP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DEXP.C + +DEXX.OBJ: F:\MATHLIB\DEXX.C $(DEXX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DEXX.C + +DFACT.OBJ: F:\MATHLIB\DFACT.C $(DFACT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DFACT.C + +DFPRINTF.OBJ: F:\MATHLIB\DFPRINTF.C $(DFPRINTF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DFPRINTF.C + +DFRACT.OBJ: F:\MATHLIB\DFRACT.C $(DFRACT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DFRACT.C + +DFREE.OBJ: F:\MATHLIB\DFREE.C $(DFREE_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DFREE.C + +DFTOD.OBJ: F:\MATHLIB\DFTOD.C $(DFTOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DFTOD.C + +DFTODR.OBJ: F:\MATHLIB\DFTODR.C $(DFTODR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DFTODR.C + +DINT.OBJ: F:\MATHLIB\DINT.C $(DINT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DINT.C + +DISEQ.OBJ: F:\MATHLIB\DISEQ.C $(DISEQ_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISEQ.C + +DISGE.OBJ: F:\MATHLIB\DISGE.C $(DISGE_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISGE.C + +DISGT.OBJ: F:\MATHLIB\DISGT.C $(DISGT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISGT.C + +DISINT.OBJ: F:\MATHLIB\DISINT.C $(DISINT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISINT.C + +DISLE.OBJ: F:\MATHLIB\DISLE.C $(DISLE_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISLE.C + +DISLT.OBJ: F:\MATHLIB\DISLT.C $(DISLT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISLT.C + +DISNE.OBJ: F:\MATHLIB\DISNE.C $(DISNE_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISNE.C + +DISNEG.OBJ: F:\MATHLIB\DISNEG.C $(DISNEG_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISNEG.C + +DISPOS.OBJ: F:\MATHLIB\DISPOS.C $(DISPOS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISPOS.C + +DISZERO.OBJ: F:\MATHLIB\DISZERO.C $(DISZERO_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DISZERO.C + +DIVARR.OBJ: F:\MATHLIB\DIVARR.C $(DIVARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVARR.C + +DIVARRD.OBJ: F:\MATHLIB\DIVARRD.C $(DIVARRD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVARRD.C + +DIVDFD.OBJ: F:\MATHLIB\DIVDFD.C $(DIVDFD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVDFD.C + +DIVID.OBJ: F:\MATHLIB\DIVID.C $(DIVID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVID.C + +DIVLD.OBJ: F:\MATHLIB\DIVLD.C $(DIVLD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVLD.C + +DIVSTR.OBJ: F:\MATHLIB\DIVSTR.C $(DIVSTR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVSTR.C + +DIVUID.OBJ: F:\MATHLIB\DIVUID.C $(DIVUID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVUID.C + +DIVULD.OBJ: F:\MATHLIB\DIVULD.C $(DIVULD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DIVULD.C + +DLN.OBJ: F:\MATHLIB\DLN.C $(DLN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DLN.C + +DLNX.OBJ: F:\MATHLIB\DLNX.C $(DLNX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DLNX.C + +DLOG.OBJ: F:\MATHLIB\DLOG.C $(DLOG_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DLOG.C + +DMAG.OBJ: F:\MATHLIB\DMAG.C $(DMAG_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMAG.C + +DMANT.OBJ: F:\MATHLIB\DMANT.C $(DMANT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMANT.C + +DMAX.OBJ: F:\MATHLIB\DMAX.C $(DMAX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMAX.C + +DMBYN.OBJ: F:\MATHLIB\DMBYN.C $(DMBYN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMBYN.C + +DMBYP10.OBJ: F:\MATHLIB\DMBYP10.C $(DMBYP10_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMBYP10.C + +DMBYP10T.OBJ: F:\MATHLIB\DMBYP10T.C $(DMBYP10T_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMBYP10T.C + +DMEAN.OBJ: F:\MATHLIB\DMEAN.C $(DMEAN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMEAN.C + +DMI.OBJ: F:\MATHLIB\DMI.C $(DMI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMI.C + +DMIN.OBJ: F:\MATHLIB\DMIN.C $(DMIN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMIN.C + +DMOD.OBJ: F:\MATHLIB\DMOD.C $(DMOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMOD.C + +DMODDF.OBJ: F:\MATHLIB\DMODDF.C $(DMODDF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMODDF.C + +DMODI.OBJ: F:\MATHLIB\DMODI.C $(DMODI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMODI.C + +DMODL.OBJ: F:\MATHLIB\DMODL.C $(DMODL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMODL.C + +DMODUI.OBJ: F:\MATHLIB\DMODUI.C $(DMODUI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMODUI.C + +DMODUL.OBJ: F:\MATHLIB\DMODUL.C $(DMODUL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMODUL.C + +DMUL.OBJ: F:\MATHLIB\DMUL.C $(DMUL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMUL.C + +DMULR.OBJ: F:\MATHLIB\DMULR.C $(DMULR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMULR.C + +DMULT.OBJ: F:\MATHLIB\DMULT.C $(DMULT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMULT.C + +DMUX.OBJ: F:\MATHLIB\DMUX.C $(DMUX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMUX.C + +DPCT.OBJ: F:\MATHLIB\DPCT.C $(DPCT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPCT.C + +DPDB.OBJ: F:\MATHLIB\DPDB.C $(DPDB_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPDB.C + +DPDBTBL.OBJ: F:\MATHLIB\DPDBTBL.C $(DPDBTBL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPDBTBL.C + +DPDDB.OBJ: F:\MATHLIB\DPDDB.C $(DPDDB_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPDDB.C + +DPDDBTBL.OBJ: F:\MATHLIB\DPDDBTBL.C $(DPDDBTBL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPDDBTBL.C + +DPOW.OBJ: F:\MATHLIB\DPOW.C $(DPOW_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPOW.C + +DPOWI.OBJ: F:\MATHLIB\DPOWI.C $(DPOWI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPOWI.C + +DPOWRAT.OBJ: F:\MATHLIB\DPOWRAT.C $(DPOWRAT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPOWRAT.C + +DPOXI.OBJ: F:\MATHLIB\DPOXI.C $(DPOXI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPOXI.C + +DPREC.OBJ: F:\MATHLIB\DPREC.C $(DPREC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPREC.C + +DPSL.OBJ: F:\MATHLIB\DPSL.C $(DPSL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPSL.C + +DPSLTBL.OBJ: F:\MATHLIB\DPSLTBL.C $(DPSLTBL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPSLTBL.C + +DPSOY.OBJ: F:\MATHLIB\DPSOY.C $(DPSOY_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPSOY.C + +DPSOYTBL.OBJ: F:\MATHLIB\DPSOYTBL.C $(DPSOYTBL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DPSOYTBL.C + +DRAD.OBJ: F:\MATHLIB\DRAD.C $(DRAD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DRAD.C + +DROOT.OBJ: F:\MATHLIB\DROOT.C $(DROOT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DROOT.C + +DROOTI.OBJ: F:\MATHLIB\DROOTI.C $(DROOTI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DROOTI.C + +DROUND.OBJ: F:\MATHLIB\DROUND.C $(DROUND_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DROUND.C + +DSETERTN.OBJ: F:\MATHLIB\DSETERTN.C $(DSETERTN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSETERTN.C + +DSIGN.OBJ: F:\MATHLIB\DSIGN.C $(DSIGN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSIGN.C + +DSIN.OBJ: F:\MATHLIB\DSIN.C $(DSIN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSIN.C + +DSINS.OBJ: F:\MATHLIB\DSINS.C $(DSINS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSINS.C + +DSORT.OBJ: F:\MATHLIB\DSORT.C $(DSORT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSORT.C + +DSPRINTF.OBJ: F:\MATHLIB\DSPRINTF.C $(DSPRINTF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSPRINTF.C + +DSQRT.OBJ: F:\MATHLIB\DSQRT.C $(DSQRT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSQRT.C + +DSQX.OBJ: F:\MATHLIB\DSQX.C $(DSQX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSQX.C + +DSUB.OBJ: F:\MATHLIB\DSUB.C $(DSUB_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSUB.C + +DSUX.OBJ: F:\MATHLIB\DSUX.C $(DSUX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSUX.C + +DSWAP.OBJ: F:\MATHLIB\DSWAP.C $(DSWAP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DSWAP.C + +DTAN.OBJ: F:\MATHLIB\DTAN.C $(DTAN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTAN.C + +DTOA.OBJ: F:\MATHLIB\DTOA.C $(DTOA_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOA.C + +DTOAC.OBJ: F:\MATHLIB\DTOAC.C $(DTOAC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOAC.C + +DTOACR.OBJ: F:\MATHLIB\DTOACR.C $(DTOACR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOACR.C + +DTOAF.OBJ: F:\MATHLIB\DTOAF.C $(DTOAF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOAF.C + +DTOAR.OBJ: F:\MATHLIB\DTOAR.C $(DTOAR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOAR.C + +DTODC.OBJ: F:\MATHLIB\DTODC.C $(DTODC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTODC.C + +DTODF.OBJ: F:\MATHLIB\DTODF.C $(DTODF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTODF.C + +DTOENG.OBJ: F:\MATHLIB\DTOENG.C $(DTOENG_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOENG.C + +DTOFR.OBJ: F:\MATHLIB\DTOFR.C $(DTOFR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOFR.C + +DTOI.OBJ: F:\MATHLIB\DTOI.C $(DTOI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOI.C + +DTOL.OBJ: F:\MATHLIB\DTOL.C $(DTOL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOL.C + +DTOSCI.OBJ: F:\MATHLIB\DTOSCI.C $(DTOSCI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOSCI.C + +DTOUI.OBJ: F:\MATHLIB\DTOUI.C $(DTOUI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOUI.C + +DTOUL.OBJ: F:\MATHLIB\DTOUL.C $(DTOUL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTOUL.C + +DTRUNC.OBJ: F:\MATHLIB\DTRUNC.C $(DTRUNC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTRUNC.C + +DTRUX.OBJ: F:\MATHLIB\DTRUX.C $(DTRUX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DTRUX.C + +DZERO.OBJ: F:\MATHLIB\DZERO.C $(DZERO_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DZERO.C + +DZEROARR.OBJ: F:\MATHLIB\DZEROARR.C $(DZEROARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DZEROARR.C + +EFFTONOM.OBJ: F:\MATHLIB\EFFTONOM.C $(EFFTONOM_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\EFFTONOM.C + +ERRNAME.OBJ: F:\MATHLIB\ERRNAME.C $(ERRNAME_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ERRNAME.C + +FRTOD.OBJ: F:\MATHLIB\FRTOD.C $(FRTOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\FRTOD.C + +FUNNAME.OBJ: F:\MATHLIB\FUNNAME.C $(FUNNAME_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\FUNNAME.C + +GCMP.OBJ: F:\MATHLIB\GCMP.C $(GCMP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\GCMP.C + +GINC.OBJ: F:\MATHLIB\GINC.C $(GINC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\GINC.C + +GMEC.OBJ: F:\MATHLIB\GMEC.C $(GMEC_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\GMEC.C + +GMEF.OBJ: F:\MATHLIB\GMEF.C $(GMEF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\GMEF.C + +GMGLOBAL.OBJ: F:\MATHLIB\GMGLOBAL.C $(GMGLOBAL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\GMGLOBAL.C + +D10BY5.OBJ: F:\MATHLIB\D10BY5.C $(D10BY5_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\D10BY5.C + +D10BY5T.OBJ: F:\MATHLIB\D10BY5T.C $(D10BY5T_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\D10BY5T.C + +GMRS.OBJ: F:\MATHLIB\GMRS.C $(GMRS_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\GMRS.C + +GMSERRI.OBJ: F:\MATHLIB\GMSERRI.C $(GMSERRI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\GMSERRI.C + +HMI.OBJ: F:\MATHLIB\HMI.C $(HMI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\HMI.C + +INTRAUX.OBJ: F:\MATHLIB\INTRAUX.C $(INTRAUX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\INTRAUX.C + +IRR.OBJ: F:\MATHLIB\IRR.C $(IRR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\IRR.C + +ITOD.OBJ: F:\MATHLIB\ITOD.C $(ITOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ITOD.C + +LINEST.OBJ: F:\MATHLIB\LINEST.C $(LINEST_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\LINEST.C + +LOOKARR.OBJ: F:\MATHLIB\LOOKARR.C $(LOOKARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\LOOKARR.C + +LTOD.OBJ: F:\MATHLIB\LTOD.C $(LTOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\LTOD.C + +MAKID.OBJ: F:\MATHLIB\MAKID.C $(MAKID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MAKID.C + +MAKLD.OBJ: F:\MATHLIB\MAKLD.C $(MAKLD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MAKLD.C + +MAKUID.OBJ: F:\MATHLIB\MAKUID.C $(MAKUID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MAKUID.C + +MAKULD.OBJ: F:\MATHLIB\MAKULD.C $(MAKULD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MAKULD.C + +MAXARR.OBJ: F:\MATHLIB\MAXARR.C $(MAXARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MAXARR.C + +MEDIAN.OBJ: F:\MATHLIB\MEDIAN.C $(MEDIAN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MEDIAN.C + +MGMN.OBJ: F:\MATHLIB\MGMN.C $(MGMN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MGMN.C + +MINARR.OBJ: F:\MATHLIB\MINARR.C $(MINARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MINARR.C + +MIRR.OBJ: F:\MATHLIB\MIRR.C $(MIRR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MIRR.C + +MLI.OBJ: F:\MATHLIB\MLI.C $(MLI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MLI.C + +MUL10.OBJ: F:\MATHLIB\MUL10.C $(MUL10_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MUL10.C + +MUL10AD.OBJ: F:\MATHLIB\MUL10AD.C $(MUL10AD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MUL10AD.C + +MUL10L.OBJ: F:\MATHLIB\MUL10L.C $(MUL10L_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MUL10L.C + +MULARR.OBJ: F:\MATHLIB\MULARR.C $(MULARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULARR.C + +MULARRD.OBJ: F:\MATHLIB\MULARRD.C $(MULARRD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULARRD.C + +MULDFD.OBJ: F:\MATHLIB\MULDFD.C $(MULDFD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULDFD.C + +MULID.OBJ: F:\MATHLIB\MULID.C $(MULID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULID.C + +MULLD.OBJ: F:\MATHLIB\MULLD.C $(MULLD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULLD.C + +MULSTR.OBJ: F:\MATHLIB\MULSTR.C $(MULSTR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULSTR.C + +MULUID.OBJ: F:\MATHLIB\MULUID.C $(MULUID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULUID.C + +MULULD.OBJ: F:\MATHLIB\MULULD.C $(MULULD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\MULULD.C + +NFV.OBJ: F:\MATHLIB\NFV.C $(NFV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\NFV.C + +NOMTOEFF.OBJ: F:\MATHLIB\NOMTOEFF.C $(NOMTOEFF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\NOMTOEFF.C + +NPV.OBJ: F:\MATHLIB\NPV.C $(NPV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\NPV.C + +PADD.OBJ: F:\MATHLIB\PADD.C $(PADD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PADD.C + +PCHANGE.OBJ: F:\MATHLIB\PCHANGE.C $(PCHANGE_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PCHANGE.C + +PDIV.OBJ: F:\MATHLIB\PDIV.C $(PDIV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PDIV.C + +PMUL.OBJ: F:\MATHLIB\PMUL.C $(PMUL_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PMUL.C + +POF.OBJ: F:\MATHLIB\POF.C $(POF_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\POF.C + +PREDX.OBJ: F:\MATHLIB\PREDX.C $(PREDX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PREDX.C + +PREDY.OBJ: F:\MATHLIB\PREDY.C $(PREDY_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PREDY.C + +PSUB.OBJ: F:\MATHLIB\PSUB.C $(PSUB_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PSUB.C + +PTOY.OBJ: F:\MATHLIB\PTOY.C $(PTOY_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\PTOY.C + +ROUNDCNT.OBJ: F:\MATHLIB\ROUNDCNT.C $(ROUNDCNT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ROUNDCNT.C + +SGMN.OBJ: F:\MATHLIB\SGMN.C $(SGMN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SGMN.C + +SIMP360.OBJ: F:\MATHLIB\SIMP360.C $(SIMP360_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SIMP360.C + +SIMP365.OBJ: F:\MATHLIB\SIMP365.C $(SIMP365_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SIMP365.C + +SIMPAUX.OBJ: F:\MATHLIB\SIMPAUX.C $(SIMPAUX_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SIMPAUX.C + +SMI.OBJ: F:\MATHLIB\SMI.C $(SMI_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SMI.C + +SPFV.OBJ: F:\MATHLIB\SPFV.C $(SPFV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SPFV.C + +SPPV.OBJ: F:\MATHLIB\SPPV.C $(SPPV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SPPV.C + +SQ5TO4.OBJ: F:\MATHLIB\SQ5TO4.C $(SQ5TO4_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SQ5TO4.C + +STNDDEV.OBJ: F:\MATHLIB\STNDDEV.C $(STNDDEV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\STNDDEV.C + +SUBARR.OBJ: F:\MATHLIB\SUBARR.C $(SUBARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBARR.C + +SUBARRD.OBJ: F:\MATHLIB\SUBARRD.C $(SUBARRD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBARRD.C + +SUBDFD.OBJ: F:\MATHLIB\SUBDFD.C $(SUBDFD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBDFD.C + +SUBID.OBJ: F:\MATHLIB\SUBID.C $(SUBID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBID.C + +SUBLD.OBJ: F:\MATHLIB\SUBLD.C $(SUBLD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBLD.C + +SUBSTR.OBJ: F:\MATHLIB\SUBSTR.C $(SUBSTR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBSTR.C + +SUBUID.OBJ: F:\MATHLIB\SUBUID.C $(SUBUID_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBUID.C + +SUBULD.OBJ: F:\MATHLIB\SUBULD.C $(SUBULD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUBULD.C + +SUMARR.OBJ: F:\MATHLIB\SUMARR.C $(SUMARR_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUMARR.C + +SUMARRN.OBJ: F:\MATHLIB\SUMARRN.C $(SUMARRN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUMARRN.C + +SUMARRP.OBJ: F:\MATHLIB\SUMARRP.C $(SUMARRP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\SUMARRP.C + +TRUNCCNT.OBJ: F:\MATHLIB\TRUNCCNT.C $(TRUNCCNT_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\TRUNCCNT.C + +UITOD.OBJ: F:\MATHLIB\UITOD.C $(UITOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\UITOD.C + +ULTOD.OBJ: F:\MATHLIB\ULTOD.C $(ULTOD_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\ULTOD.C + +USFV.OBJ: F:\MATHLIB\USFV.C $(USFV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\USFV.C + +USPV.OBJ: F:\MATHLIB\USPV.C $(USPV_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\USPV.C + +WMEAN.OBJ: F:\MATHLIB\WMEAN.C $(WMEAN_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\WMEAN.C + +YTOP.OBJ: F:\MATHLIB\YTOP.C $(YTOP_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\YTOP.C + +DLLGFM.OBJ: DLLGFM.C $(DLLGFM_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c DLLGFM.C + +DMBY1.OBJ: F:\MATHLIB\DMBY1.C $(DMBY1_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMBY1.C + +DMBY1R.OBJ: F:\MATHLIB\DMBY1R.C $(DMBY1R_DEP) + $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c F:\MATHLIB\DMBY1R.C + + +$(PROJ).DLL:: ADATE360.OBJ ADATE365.OBJ ADATENLY.OBJ ADDARR.OBJ ADDARRD.OBJ ADDDFD.OBJ \ + ADDID.OBJ ADDLD.OBJ ADDSTR.OBJ ADDUID.OBJ ADDULD.OBJ ADVPMT.OBJ AGMN.OBJ AMORT.OBJ \ + AMORTTBL.OBJ ATOD.OBJ ATODR.OBJ BONDPRC.OBJ BONDYLD.OBJ COMP.OBJ COMPAUX.OBJ COMPCOMP.OBJ \ + COMPSIMP.OBJ DABS.OBJ DACOS.OBJ DADD.OBJ DADX.OBJ DALLOC.OBJ DALOG.OBJ DARALLOC.OBJ \ + DARCPY.OBJ DARFREE.OBJ DASIN.OBJ DATAN.OBJ DATAX.OBJ DBD360.OBJ DBD365.OBJ DBDNLY.OBJ \ + DCHGS.OBJ DCHIX.OBJ DCMP.OBJ DCOS.OBJ DCOSS.OBJ DCOT.OBJ DCOX.OBJ DCPY.OBJ DCTOD.OBJ \ + DDEG.OBJ DDIV.OBJ DDIVPF.OBJ DDIVPR.OBJ DDIVPT.OBJ DDIVR.OBJ DDIVT.OBJ DDIX.OBJ DDIXF.OBJ \ + DDIXR.OBJ DDIXT.OBJ DELTRZ.OBJ DEXP.OBJ DEXX.OBJ DFACT.OBJ DFPRINTF.OBJ DFRACT.OBJ \ + DFREE.OBJ DFTOD.OBJ DFTODR.OBJ DINT.OBJ DISEQ.OBJ DISGE.OBJ DISGT.OBJ DISINT.OBJ \ + DISLE.OBJ DISLT.OBJ DISNE.OBJ DISNEG.OBJ DISPOS.OBJ DISZERO.OBJ DIVARR.OBJ DIVARRD.OBJ \ + DIVDFD.OBJ DIVID.OBJ DIVLD.OBJ DIVSTR.OBJ DIVUID.OBJ DIVULD.OBJ DLN.OBJ DLNX.OBJ \ + DLOG.OBJ DMAG.OBJ DMANT.OBJ DMAX.OBJ DMBYN.OBJ DMBYP10.OBJ DMBYP10T.OBJ DMEAN.OBJ \ + DMI.OBJ DMIN.OBJ DMOD.OBJ DMODDF.OBJ DMODI.OBJ DMODL.OBJ DMODUI.OBJ DMODUL.OBJ DMUL.OBJ \ + DMULR.OBJ DMULT.OBJ DMUX.OBJ DPCT.OBJ DPDB.OBJ DPDBTBL.OBJ DPDDB.OBJ DPDDBTBL.OBJ \ + DPOW.OBJ DPOWI.OBJ DPOWRAT.OBJ DPOXI.OBJ DPREC.OBJ DPSL.OBJ DPSLTBL.OBJ DPSOY.OBJ \ + DPSOYTBL.OBJ DRAD.OBJ DROOT.OBJ DROOTI.OBJ DROUND.OBJ DSETERTN.OBJ DSIGN.OBJ DSIN.OBJ \ + DSINS.OBJ DSORT.OBJ DSPRINTF.OBJ DSQRT.OBJ DSQX.OBJ DSUB.OBJ DSUX.OBJ DSWAP.OBJ DTAN.OBJ \ + DTOA.OBJ DTOAC.OBJ DTOACR.OBJ DTOAF.OBJ DTOAR.OBJ DTODC.OBJ DTODF.OBJ DTOENG.OBJ \ + DTOFR.OBJ DTOI.OBJ DTOL.OBJ DTOSCI.OBJ DTOUI.OBJ DTOUL.OBJ DTRUNC.OBJ DTRUX.OBJ DZERO.OBJ \ + DZEROARR.OBJ EFFTONOM.OBJ ERRNAME.OBJ FRTOD.OBJ FUNNAME.OBJ GCMP.OBJ GINC.OBJ GMEC.OBJ \ + GMEF.OBJ GMGLOBAL.OBJ D10BY5.OBJ D10BY5T.OBJ GMRS.OBJ GMSERRI.OBJ HMI.OBJ INTRAUX.OBJ \ + IRR.OBJ ITOD.OBJ LINEST.OBJ LOOKARR.OBJ LTOD.OBJ MAKID.OBJ MAKLD.OBJ MAKUID.OBJ MAKULD.OBJ \ + MAXARR.OBJ MEDIAN.OBJ MGMN.OBJ MINARR.OBJ MIRR.OBJ MLI.OBJ MUL10.OBJ MUL10AD.OBJ \ + MUL10L.OBJ MULARR.OBJ MULARRD.OBJ MULDFD.OBJ MULID.OBJ MULLD.OBJ MULSTR.OBJ MULUID.OBJ \ + MULULD.OBJ NFV.OBJ NOMTOEFF.OBJ NPV.OBJ PADD.OBJ PCHANGE.OBJ PDIV.OBJ PMUL.OBJ POF.OBJ \ + PREDX.OBJ PREDY.OBJ PSUB.OBJ PTOY.OBJ ROUNDCNT.OBJ SGMN.OBJ SIMP360.OBJ SIMP365.OBJ \ + SIMPAUX.OBJ SMI.OBJ SPFV.OBJ SPPV.OBJ SQ5TO4.OBJ STNDDEV.OBJ SUBARR.OBJ SUBARRD.OBJ \ + SUBDFD.OBJ SUBID.OBJ SUBLD.OBJ SUBSTR.OBJ SUBUID.OBJ SUBULD.OBJ SUMARR.OBJ SUMARRN.OBJ \ + SUMARRP.OBJ TRUNCCNT.OBJ UITOD.OBJ ULTOD.OBJ USFV.OBJ USPV.OBJ WMEAN.OBJ YTOP.OBJ \ + DLLGFM.OBJ DMBY1.OBJ DMBY1R.OBJ $(OBJS_EXT) $(DEFFILE) + echo >NUL @<<$(PROJ).CRF +ADATE360.OBJ + +ADATE365.OBJ + +ADATENLY.OBJ + +ADDARR.OBJ + +ADDARRD.OBJ + +ADDDFD.OBJ + +ADDID.OBJ + +ADDLD.OBJ + +ADDSTR.OBJ + +ADDUID.OBJ + +ADDULD.OBJ + +ADVPMT.OBJ + +AGMN.OBJ + +AMORT.OBJ + +AMORTTBL.OBJ + +ATOD.OBJ + +ATODR.OBJ + +BONDPRC.OBJ + +BONDYLD.OBJ + +COMP.OBJ + +COMPAUX.OBJ + +COMPCOMP.OBJ + +COMPSIMP.OBJ + +DABS.OBJ + +DACOS.OBJ + +DADD.OBJ + +DADX.OBJ + +DALLOC.OBJ + +DALOG.OBJ + +DARALLOC.OBJ + +DARCPY.OBJ + +DARFREE.OBJ + +DASIN.OBJ + +DATAN.OBJ + +DATAX.OBJ + +DBD360.OBJ + +DBD365.OBJ + +DBDNLY.OBJ + +DCHGS.OBJ + +DCHIX.OBJ + +DCMP.OBJ + +DCOS.OBJ + +DCOSS.OBJ + +DCOT.OBJ + +DCOX.OBJ + +DCPY.OBJ + +DCTOD.OBJ + +DDEG.OBJ + +DDIV.OBJ + +DDIVPF.OBJ + +DDIVPR.OBJ + +DDIVPT.OBJ + +DDIVR.OBJ + +DDIVT.OBJ + +DDIX.OBJ + +DDIXF.OBJ + +DDIXR.OBJ + +DDIXT.OBJ + +DELTRZ.OBJ + +DEXP.OBJ + +DEXX.OBJ + +DFACT.OBJ + +DFPRINTF.OBJ + +DFRACT.OBJ + +DFREE.OBJ + +DFTOD.OBJ + +DFTODR.OBJ + +DINT.OBJ + +DISEQ.OBJ + +DISGE.OBJ + +DISGT.OBJ + +DISINT.OBJ + +DISLE.OBJ + +DISLT.OBJ + +DISNE.OBJ + +DISNEG.OBJ + +DISPOS.OBJ + +DISZERO.OBJ + +DIVARR.OBJ + +DIVARRD.OBJ + +DIVDFD.OBJ + +DIVID.OBJ + +DIVLD.OBJ + +DIVSTR.OBJ + +DIVUID.OBJ + +DIVULD.OBJ + +DLN.OBJ + +DLNX.OBJ + +DLOG.OBJ + +DMAG.OBJ + +DMANT.OBJ + +DMAX.OBJ + +DMBYN.OBJ + +DMBYP10.OBJ + +DMBYP10T.OBJ + +DMEAN.OBJ + +DMI.OBJ + +DMIN.OBJ + +DMOD.OBJ + +DMODDF.OBJ + +DMODI.OBJ + +DMODL.OBJ + +DMODUI.OBJ + +DMODUL.OBJ + +DMUL.OBJ + +DMULR.OBJ + +DMULT.OBJ + +DMUX.OBJ + +DPCT.OBJ + +DPDB.OBJ + +DPDBTBL.OBJ + +DPDDB.OBJ + +DPDDBTBL.OBJ + +DPOW.OBJ + +DPOWI.OBJ + +DPOWRAT.OBJ + +DPOXI.OBJ + +DPREC.OBJ + +DPSL.OBJ + +DPSLTBL.OBJ + +DPSOY.OBJ + +DPSOYTBL.OBJ + +DRAD.OBJ + +DROOT.OBJ + +DROOTI.OBJ + +DROUND.OBJ + +DSETERTN.OBJ + +DSIGN.OBJ + +DSIN.OBJ + +DSINS.OBJ + +DSORT.OBJ + +DSPRINTF.OBJ + +DSQRT.OBJ + +DSQX.OBJ + +DSUB.OBJ + +DSUX.OBJ + +DSWAP.OBJ + +DTAN.OBJ + +DTOA.OBJ + +DTOAC.OBJ + +DTOACR.OBJ + +DTOAF.OBJ + +DTOAR.OBJ + +DTODC.OBJ + +DTODF.OBJ + +DTOENG.OBJ + +DTOFR.OBJ + +DTOI.OBJ + +DTOL.OBJ + +DTOSCI.OBJ + +DTOUI.OBJ + +DTOUL.OBJ + +DTRUNC.OBJ + +DTRUX.OBJ + +DZERO.OBJ + +DZEROARR.OBJ + +EFFTONOM.OBJ + +ERRNAME.OBJ + +FRTOD.OBJ + +FUNNAME.OBJ + +GCMP.OBJ + +GINC.OBJ + +GMEC.OBJ + +GMEF.OBJ + +GMGLOBAL.OBJ + +D10BY5.OBJ + +D10BY5T.OBJ + +GMRS.OBJ + +GMSERRI.OBJ + +HMI.OBJ + +INTRAUX.OBJ + +IRR.OBJ + +ITOD.OBJ + +LINEST.OBJ + +LOOKARR.OBJ + +LTOD.OBJ + +MAKID.OBJ + +MAKLD.OBJ + +MAKUID.OBJ + +MAKULD.OBJ + +MAXARR.OBJ + +MEDIAN.OBJ + +MGMN.OBJ + +MINARR.OBJ + +MIRR.OBJ + +MLI.OBJ + +MUL10.OBJ + +MUL10AD.OBJ + +MUL10L.OBJ + +MULARR.OBJ + +MULARRD.OBJ + +MULDFD.OBJ + +MULID.OBJ + +MULLD.OBJ + +MULSTR.OBJ + +MULUID.OBJ + +MULULD.OBJ + +NFV.OBJ + +NOMTOEFF.OBJ + +NPV.OBJ + +PADD.OBJ + +PCHANGE.OBJ + +PDIV.OBJ + +PMUL.OBJ + +POF.OBJ + +PREDX.OBJ + +PREDY.OBJ + +PSUB.OBJ + +PTOY.OBJ + +ROUNDCNT.OBJ + +SGMN.OBJ + +SIMP360.OBJ + +SIMP365.OBJ + +SIMPAUX.OBJ + +SMI.OBJ + +SPFV.OBJ + +SPPV.OBJ + +SQ5TO4.OBJ + +STNDDEV.OBJ + +SUBARR.OBJ + +SUBARRD.OBJ + +SUBDFD.OBJ + +SUBID.OBJ + +SUBLD.OBJ + +SUBSTR.OBJ + +SUBUID.OBJ + +SUBULD.OBJ + +SUMARR.OBJ + +SUMARRN.OBJ + +SUMARRP.OBJ + +TRUNCCNT.OBJ + +UITOD.OBJ + +ULTOD.OBJ + +USFV.OBJ + +USPV.OBJ + +WMEAN.OBJ + +YTOP.OBJ + +DLLGFM.OBJ + +DMBY1.OBJ + +DMBY1R.OBJ + +$(OBJS_EXT) +$(PROJ).DLL +$(MAPFILE) +c:\msvc\lib\+ +$(LIBS) +$(DEFFILE); +<< + link $(LFLAGS) @$(PROJ).CRF + $(RC) $(RESFLAGS) $@ + implib /nowep $(PROJ).LIB $(PROJ).DLL + + +run: $(PROJ).DLL + $(PROJ) $(RUNFLAGS) + + +$(PROJ).BSC: $(SBRS) + bscmake @<< +/o$@ $(SBRS) +<< diff --git a/gfm/dln.c b/gfm/dln.c new file mode 100755 index 000000000..02838636a --- /dev/null +++ b/gfm/dln.c @@ -0,0 +1,65 @@ +/* DEC *LogEDecimal(pDst,pSrc) + * ARGUMENT + * pDst is a DEC pointer to the destination. + * pSrc is a DEC pointer to the source. + * + * DESCRIPTION + * Takes the natural logarithm of pSrc, storing result in pDst. + * + * SIDE EFFECTS + * pDst is indeterminate on error. + * Possible errors: + * GM_NULLPOINTER + * GM_IMAG if pSrc <= 0 + * Note: overflow and underflow are not possible. + * + * RETURNS + * pDst if successful, GM_NULL otherwise. + * + * ALGORTIHM + * pSrc = 10^m * 2^(-d) * x .7 <= x < 1.4 + * z = (x - 1) / (x + 1) + * ln pSrc = m * ln 10 - d * ln 2 + ln x + * ln x = 2 * SUM [z^(2 * n + 1) / (2 * n + 1)] + * n = 0, 1, 2, 3,... + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * GM_IMAG + * + * AUTHOR + * Jared Levy 4 / 8 / 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *LogEDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + int i; + + _MacStart(GM_DLN); + + _MacInVar(pSrc,GM_NULL); + _MacOutVar(pDst,GM_NULL); + + i = _LnDec80Bit(pDst, pSrc); + if (i != GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + + /* following cannot be unsuccessful */ + (void) _Sq5UnsTo4Uns(pDst); + + _MacRet(pDst); +} diff --git a/gfm/dlnx.c b/gfm/dlnx.c new file mode 100755 index 000000000..708ca0aaf --- /dev/null +++ b/gfm/dlnx.c @@ -0,0 +1,100 @@ +/* int _LnDec80Bit(pDst,pSrc) + * ARGUMENT + * pDst is a DEC pointer to the destination. + * pSrc is a DEC pointer to the source. + * + * DESCRIPTION + * Takes the natural logarithm of pSrc, storing result in pDst. + * + * SIDE EFFECTS + * Possible errors: + * GM_NULLPOINTER + * GM_IMAG if pSrc <= 0 + * GM_OVERFLOW if pSrc >= 0 and overflow occurs + * + * RETURNS + * GM_SUCCESS if successful, error code otherwise. + * + * ALGORTIHM + * pSrc = 10^m * 2^(-d) * x .7 <= x < 1.4 + * z = (x - 1) / (x + 1) + * ln pSrc = m * ln 10 - d * ln 2 + ln x + * ln x = 2 * SUM [z^(2 * n + 1) / (2 * n + 1)] + * n = 0, 1, 2, 3,... + * + * AUTHOR + * Jared Levy 4 / 8 / 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _LnDec80Bit(pDst,pSrc) +DEC *pDst, *pSrc; +{ + + int m; + DEC *pm, dm, *nsrc, dnsrc, *one, *num, dnum; + DEC *den, dden, *z, dz, *zsq, dzsq, *pdt, dterm, *fact, dfact; + DEC *powz, dpowz; + + if (!_MacIsDecP(pSrc)) + return(GM_IMAG); + +/* find order of magnitude and normalize to range .1 < nsrc < 1 */ + m = MagnitudeOfDecimal(pSrc) + 1; + nsrc = &dnsrc; + _MacDCopy(nsrc, pSrc); + nsrc->dc.id += m; + if (nsrc->dc.id > GM_IMAXID) { + _DivUnsArrByPwrOf10(nsrc->dc.sl, 5, nsrc->dc.id-GM_IMAXID); + nsrc->dc.id = GM_IMAXID; + } +/* calculate m * ln(10) */ + pm = ConvLongToDecimal(&dm, (long) m); + (void) _MulDec80Bit(pDst, &decLn10, pm); + +/* normalize to .7 < nsrc <= 1.4, adjust by factors of log 2 */ + while (CompareDecimal(nsrc, &decPoint7) <= 0) { + /* double nsrc */ + (void) _AddDec80Bit(nsrc, nsrc, nsrc); + /* subtract a ln 2 */ + (void) _SubDec80Bit(pDst, pDst, &decLn2); + } + +/* calculate z = (nsrc - 1) / (nsrc + 1) */ + one = &decOne; + num = &dnum; + (void) _SubDec80Bit(&dnum, nsrc, one); + den = &dden; + (void) _AddDec80Bit(&dden, nsrc, one); + z = &dz; + (void) _DivRndDec80Bit(&dz, num, den, 23); + +/* calculate log nsrc as an expansion of z */ + zsq = &dzsq; + (void) _MulDec80Bit(&dzsq, z, z); + fact = ConvLongToDecimal(&dfact, 3L); + powz = &dpowz; + /* first term is 2 * z */ + (void) _AddDec80Bit(powz, z, z); + (void) _AddDec80Bit(pDst, pDst, powz); + pdt = &dterm; + do { + /* powz = z^(2n+1) */ + (void) _MulDec80Bit(powz, powz, zsq); + /* term = powz/(2n+1) */ + (void) _DivRndDec80Bit(&dterm, powz, fact,23); + /* then add new term */ + (void) _AddDec80Bit(pDst, pDst, pdt); + /* and increase factorial count */ + fact->dc.sl[0] += 2; + } while (!(_MacIsDecZ(pdt))); + + return(GM_SUCCESS); +} diff --git a/gfm/dlog.c b/gfm/dlog.c new file mode 100755 index 000000000..feaa5ae43 --- /dev/null +++ b/gfm/dlog.c @@ -0,0 +1,66 @@ +/* DEC *Log10Decimal(pDst,pSrc) + * ARGUMENT + * pDst is a DEC pointer to the destination. + * pSrc is a DEC pointer to the source. + * + * DESCRIPTION + * Takes the base 10 logarithm of pSrc, storing result in pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, GM_NULL otherwise. + * + * ALGORTIHM + * log x = (1/ln10) * ln(x), with ln(x) calculated as: + * + * pSrc = 10^m * 2^(-d) * x .7 <= x < 1.4 + * z = (x - 1) / (x + 1) + * ln pSrc = m * ln 10 - d * ln 2 + ln x + * ln x = 2 * SUM [z^(2 * n + 1) / (2 * n + 1)] + * n = 0, 1, 2, 3,... + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_IMAG + * + * AUTHOR + * Jared Levy 4 / 8 / 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *Log10Decimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + DEC dtemp, *temp=&dtemp; + + _MacStart(GM_DLOG); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + if (!_MacIsDecP(pSrc)) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + + _MacDZero(temp); + /* first take ln(pSrc) */ + (void) _LnDec80Bit(temp, pSrc); /* can't fail if pSrc is positive */ + /* then (1/ln(10))* ln(pSrc) */ + (void) _MulDec80Bit(pDst, &decReciprocalOfLn10, temp); + /* then back to 64-bit */ + (void) _Sq5UnsTo4Uns(pDst); /* cannot be unsuccessful */ + + _MacRet(pDst); +} diff --git a/gfm/dmag.c b/gfm/dmag.c new file mode 100755 index 000000000..a1316892e --- /dev/null +++ b/gfm/dmag.c @@ -0,0 +1,59 @@ +/* int MagnitudeOfDecimal(pSrc); + * ARGUMENT + * DEC *pSrc; + * + * DESCRIPTION + * returns the 'order of magnitude' of pSrc -- the exponent of the + * largest power of 10 less than or equal to absolute value of pSrc. + * Examples: MagnitudeOfDecimal(20) = 1 + * MagnitudeOfDecimal(200)=2 + * MagnitudeOfDecimal(2)=0 + * MagnitudeOfDecimal(-.2) = -1 + * MagnitudeOfDecimal(1)=0 + * MagnitudeOfDecimal(3.14)=0 + * MagnitudeOfDecimal(.003)= -3 + * MagnitudeOfDecimal(0) = -32767 + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The magnitude of pSrc. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy 5 / 18 / 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int MagnitudeOfDecimal(pSrc) +DEC *pSrc; +{ + SHORT p; + + _MacStart(GM_DMAG); + _MacInVarI(pSrc); + + if (_MacIsDecZ(pSrc)) + _MacRet( -32767); + +/* finds pSrc->dc.sl in wrgGMPowersOfTen80Bit[] using a linear search */ +/* of 80-bit unsigned values */ + p = 1; + while ((p<=24) && + (_CompareUnsArr(pSrc->dc.sl, + &wrgGMPowersOfTen80Bit[5*p], 5) != -1)) + p++; + + _MacRet(p - 1 - pSrc->dc.id); +} diff --git a/gfm/dmant.c b/gfm/dmant.c new file mode 100755 index 000000000..23417fe6b --- /dev/null +++ b/gfm/dmant.c @@ -0,0 +1,69 @@ +/* long DecimalMantissa(pSrc); + * + * ARGUMENT + * DEC *pSrc; + * + * DESCRIPTION + * Finds the mantissa of pSrc. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The mantissa, or an error code + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +long DecimalMantissa(pSrc) +DEC *pSrc; +{ + long l; + + _MacStart(GM_DMANT); + + if (!pSrc) { + _MacErr(GM_NULLPOINTER); + _MacRet((long) GM_NULLPOINTER); + } + if (_MacBad(pSrc)) { + _MacErr(GM_INIT); + _MacRet((long) GM_INIT); + } + + if (pSrc->ls.lsl[1] || pSrc->ls.lmsd) { + _MacErr(GM_OVERFLOW); + l = (long) GM_OVERFLOW; + _MacRet(l); + } + + if (pSrc->ls.lsl[0]&0x80000000L) { + if ((pSrc->ls.lsl[0]!=0x80000000L) || !_MacIsDecN(pSrc)) { + _MacErr(GM_OVERFLOW); + _MacRet((long) GM_OVERFLOW); + } + else + _MacRet((long) 0x80000000L); + } + + l = pSrc->ls.lsl[0]; + if (_MacIsDecN(pSrc)) + {_MacRet(-l);} + else + {_MacRet(l);} +} diff --git a/gfm/dmax.c b/gfm/dmax.c new file mode 100755 index 000000000..243e9ceae --- /dev/null +++ b/gfm/dmax.c @@ -0,0 +1,53 @@ +/* DEC *MaximumDecimal(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pSrc1,*pSrc2,*pDst; + * + * DESCRIPTION + * Stores the larger of pSrc1 or pSrc2 in pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to pDst if successful. + * otherwise GM_NULL and sets the global error to GM_NULLPOINTER. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * + * AUTHOR + * AA 17-Sep-87 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MaximumDecimal(pDst,pSrc1,pSrc2) +DEC *pSrc1,*pSrc2,*pDst; +{ + + int i; + + _MacStart(GM_DMAX); + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + _MacOutVarD(pDst); + + i = CompareDecimal(pSrc1,pSrc2); + + if(i<0) + _MacDCopy(pDst,pSrc2); + else + _MacDCopy(pDst,pSrc1); + + return(pDst); +} diff --git a/gfm/dmby1.asm b/gfm/dmby1.asm new file mode 100755 index 000000000..a2a2ca6d0 --- /dev/null +++ b/gfm/dmby1.asm @@ -0,0 +1,101 @@ + ; int _DivUnsArrByUns(a, c, n) + ; + ; ARGUMENT + ; unsigned a[] n-word number to divide + ; unsigned c number of divide by + ; int n number of digits + ; + ; DESCRIPTION + ; Divides n-digit number c by b, storing result in c. + ; The (positive) remainder is calculated and returned. + ; + ; SIDE EFFECTS + ; None. + ; + ; RETURNS + ; Remainder. + ; + ; AUTHOR + ; Jared Levy 7/9/89 + ; Copyright (C) 1989-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; + ; + ; + include model.h + include prologue.h + include gm.equ + + pseg dmby1 + cproc _DivUnsArrByUns,,_dmby1 + +; load parameters +if _LDATA + push es + les di, parm1_ ; get pointer to source & destination + mov cx, parm3_ ; get number to divide by + mov bx, parm4_ ; get number of digits +else + mov di, parm1_ ; get pointer to source & destination + mov ax, ds + mov es, ax + mov cx, parm2_ ; get number to divide by + mov bx, parm3_ ; get number of digits +endif + call near ptr dmby1a +if _LDATA + pop es +endif + cproce + +; the computation routine is separate so it may be called from assembly +dmby1a: + dec bx ; digits go from 0 to n-1 + sal bx, 1 ; want bytes rather than words + +;/* skip initial zeroes */ +; for(;(q>0)&&(c[q-1]==0);q--); +; +; if (q == 0) +; return(0); +; q--; /* q will be used for subscript */ +zeroloop: + mov ax, word ptr es:[di+bx] ; get digit + cmp ax, 0 ; is digit zero? + jne nonzero ; if non-zero, begin divide + dec bx ; next word + dec bx + cmp bx, 0 ; last digit? + jge zeroloop ; if not, process next digit + xor ax, ax ; otherwise, remainder 0 + jmp short exit1 ; && division through (0/c=0) + +; bl = (unsigned long) b; +; while (q>=0) { +; k = (unsigned long *) &r[q]; +; cl = *k / bl; +; c[q] = (unsigned) cl; +; r[q] = (unsigned) (*k - cl * bl); +; q--; +; } +nonzero: + xor dx,dx ; high word zero in first divide +divloop: + div cx ; divide digit + mov word ptr es:[di+bx], ax ; store quotient digit + cmp bx, 0 ; last digit? + je exit2 ; if so, division complete + dec bx ; next digit + dec bx + mov ax, word ptr es:[di+bx] ; get digit + jmp short divloop ; process digit + +exit2: + mov ax, dx ; return remainder +exit1: + ret + + endps + end + diff --git a/gfm/dmby1.c b/gfm/dmby1.c new file mode 100755 index 000000000..822d0d4e5 --- /dev/null +++ b/gfm/dmby1.c @@ -0,0 +1,51 @@ +/* unsigned _DivUnsArrByUns(a,c,n) + * + * ARGUMENT + * unsigned a[]; + * unsigned c; number of divide by + * int n; number of digits + * + * DESCRIPTION + * Divides a number of n digits (a) by c and stores the result in a. + * The remainder is calculated and returnes. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Remainder. + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +unsigned _DivUnsArrByUns(a,c,n) +unsigned SHORT a[],c; +int n; +{ + int i; + unsigned SHORT rem,qt; + unsigned long remup,ntbd; + + rem=0; + + if ((c)&&(n)) + { + for (i=n-1;i>=0;i--) + { + remup=(long)rem<0)&&(c[q-1]==0);q--); +; +; if (q == 0) +; return(0); +; q--; /* q will be used for subscript */ +zeroloop: + mov ax, word ptr es:[di+bx] ; get digit + cmp ax, 0 ; is digit zero? + jne nonzero ; if non-zero, begin divide + dec bx ; next word + dec bx + cmp bx, 0 ; last digit? + jge zeroloop ; if not, process next digit +; xor ax, ax ; otherwise, remainder 0 + jmp short exit1 ; && division through (0/c=0) + +; bl = (unsigned long) b; +; while (q>=0) { +; k = (unsigned long *) &r[q]; +; cl = *k / bl; +; c[q] = (unsigned) cl; +; r[q] = (unsigned) (*k - cl * bl); +; q--; +; } +nonzero: + xor dx,dx ; high word zero in first divide +divloop: + div cx ; divide digit + mov word ptr es:[di+bx], ax ; store quotient digit + cmp bx, 0 ; last digit? + je exit2 ; if so, division complete + dec bx ; next digit + dec bx + mov ax, word ptr es:[di+bx] ; get digit + jmp short divloop ; process digit + +; round up if remainder > (divisor-1)/2 +exit2: + dec cx ; set cx = (cx-1)/2 + sar cx, 1 + cmp dx, cx ; test for rounding up + ja inclp ; if remainder is large, round up + ret +inclp: + inc word ptr es:[di] + jnz exit1 + inc di + inc di + jmp short inclp + +exit1: + ret + + endps + end diff --git a/gfm/dmby1r.c b/gfm/dmby1r.c new file mode 100755 index 000000000..d5a6be964 --- /dev/null +++ b/gfm/dmby1r.c @@ -0,0 +1,56 @@ +/* void _DivUnsArrByUnsRound(a,c,n) + * + * ARGUMENT + * unsigned a[]; + * unsigned c; number of divide by + * int n; number of digits + * + * DESCRIPTION + * Divides a number of n digits (a) by c and stores the result in a. + * The quotient is rounded to the nearest integer. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _DivUnsArrByUnsRound(a,c,n) +unsigned SHORT a[],c; +int n; +{ + int i; + unsigned SHORT rem,qt; + unsigned long remup,ntbd; + float limit; + + rem=0; + + if ((c)&&(n)) + { + for (i=n-1;i>=0;i--) + { + remup=(long)rem<limit) + { + a[0]++; + } + } +} diff --git a/gfm/dmbyn.asm b/gfm/dmbyn.asm new file mode 100755 index 000000000..4b23c12cd --- /dev/null +++ b/gfm/dmbyn.asm @@ -0,0 +1,326 @@ + ; void _DivUnsArrByUnsArr(c, a, m, b, n, rf) + ; + ; ARGUMENT + ; unsigned a[], b[], c[]; + ; int m, n; + ; int rf; + ; + ; DESCRIPTION + ; Divides an m-word integer a by an n-integer word b, storing the result + ; in c. a and b must both be positive, and m >= n. The quotient is + ; rounded when rf is set, otherwise is it truncated. + ; + ; SIDE EFFECTS + ; None. + ; + ; RETURNS + ; None. + ; + ; AUTHOR + ; Jared Levy 7/9/89 + ; Copyright (C) 1989-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; + ; + ; + include model.h + include prologue.h + include gm.equ + + dseg dmbyn +acopm2 dw 1 dup(?) +acop dw 12 dup(?) +diga dw 1 dup(?) +bcopm2 dw 1 dup(?) +bcop dw 6 dup(?) +digb dw 1 dup(?) +digb2 dw 1 dup(?) +digbp1 dw 1 dup(?) +numquot dw 1 dup(?) +firstb dw 1 dup(?) +dstplc dw 1 dup(?) +partpr dw 6 dup (?) +quotdig dw 1 dup(?) + endds + + pseg dmbyn + cproc _DivUnsArrByUnsArr,,_dmbyn + +; load parameters +if _LDATA + push es + les si, parm6_ ; get source pointer b + mov bx, parm8_ ; get # of digits in b +else + mov ax, ds + mov es, ax + mov si, parm4_ ; get source pointer b + mov bx, parm5_ ; get # of digits in b +endif + +; copy b + mov digb, bx ; store # digits of b + mov digbp1, bx + inc digbp1 ; store 1 + # digits of b + sal bx, 1 + mov digb2, bx ; store twice # digits of b + + mov word ptr bcop[bx], 0 ; store 0 in extra word +loopcb: + dec bx ; next word + dec bx + mov ax, word ptr es:[si+bx] ; copy element of b + mov word ptr bcop[bx], ax + jnz loopcb + +if _LDATA + les si, parm3_ ; get source pointer a + mov bx, parm5_ ; get # of digits in a +else + mov si, parm2_ ; get source pointer a + mov bx, parm3_ ; get # of digits in a +endif + +; copy a + mov diga, bx ; store # digits of a + sal bx, 1 + xor ax, ax + mov acop[bx], ax ; store zero in extra word +loopca: + dec bx ; next word + dec bx + mov ax, word ptr es:[si+bx] ; copy element of a + mov word ptr acop[bx], ax + jnz loopca + +; rotate b and a left until high bit of b is set + mov bx, digb2 + mov ax, bcopm2[bx] ; get high word of b + mov firstb, ax + rcl ax,1 ; see if high bit set + jc noshift + + xor dx,dx +shwb: + xor bx,bx ; start shifting at low digit + mov cx,digb + clc +shblp: + rcl bcop[bx],1 ; rotate digit left + inc bx ; next digit + inc bx + loop shblp + + inc dx ; keep track of # of shifts + mov ax, bcopm2[bx] ; get high word of b + rcl ax,1 ; see if high bit set + jnc shwb + mov ax, bcopm2[bx] ; get first digit of b + mov firstb, ax ; & store + +shwa: + xor bx,bx ; start shifting at low digit + mov cx,diga + inc cx ; shift extra digit of a + clc +shalp: + rcl acop[bx],1 ; rotate digit left + inc bx ; next digit + inc bx + loop shalp + + dec dx + jnz shwa + +noshift: +; set up source and destination pointers +if _LDATA + les di, parm1_ ; get destination pointer c +else + mov di, parm1_ ; get destination pointer c +endif +; zero destination + mov bx, 8d + xor ax, ax +zerocl: + mov word ptr es:[di+bx], ax + dec bx + dec bx + jns zerocl + + mov ax, diga ; find location to store digits + sub ax, digb ; highest digit stored in word # diga - digb + jns nxtline ; if b has more digits than a, done + jmp done +nxtline: + mov numquot, ax + inc numquot ; compute number of quotient digits + sal ax, 1 + add di, ax ; where highest quotient digit stored + mov dstplc, di + + mov di, ax ; place to begin first subtraction + mov ax, diga + sal ax, 1 + mov si, ax ; place to begin first compare + +; if first digit of b is larger than first digit of a, +; first digit of quotient is 0 + mov ax, 0 + cmp ax, acop[si] + jne firstn0 + mov ax, firstb ; get high digit of b + cmp ax, acopm2[si] ; compare to high digit of a + jbe firstn0 ; first quot. digit non-zero + + dec numquot ; otherwise, one less quotient digit + jnz nline2 ; if a a, quotient too big + dec bx ; if equal compare next digit + dec bx + jns cmplp ; if b=a, compare remaining digits + jmp short worksout ; if exactly equal quotient right + +toolarge: +; when quotient too large, decrease quotient & adjust partial product + dec quotdig ; lower quotient by 1 + mov bx, 0 ; subtract b from partial prod. + clc + mov cx, digbp1 +subtllp: + mov ax, bcop[bx] ; get dig of b + sbb partpr[bx], ax ; subtract from partial prod. + inc bx ; next digit + inc bx + loop subtllp + dec bx ; bx must have right value for cmp + dec bx + jmp short cmplp + +worksout: +; store quotient digit + mov bx, dstplc + mov ax, quotdig + mov es:[bx], ax + +; subtract number + mov cx, digbp1 ; set counter for number of subtractions + xor bx, bx + clc +sloop: + mov ax, partpr[bx] ; subtract a digit at a time + sbb acop[di+bx], ax + inc bx + inc bx + loop sloop + + dec numquot + jz done + jmp wordloop + +done: +; handle rounding +if _LDATA + mov ax, parm9_ ; get rounding flag +else + mov ax, parm6_ ; get rounding flag +endif + cmp ax, 0 ; check if rounding flag set + je noround + +; see if r >= b/2 + mov cx, digbp1 + mov si, 0 + clc +dloop: + rcl word ptr acop[si], 1 ; double remainder + inc si + inc si + loop dloop + +; compare 2*r & b + mov bx, digb2 +comrl: + mov ax, acop[bx] + cmp ax, bcop[bx] ; compare digit + ja round ; a>b/2 + jb noround ; a=n. The quotient is rounded when rf is set, + * otherwise it is truncated. + * + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + +void _DivUnsArrByUnsArr(c,a,m,b,n,rf) +unsigned SHORT a[],c[],b[]; +int n,m,rf; +{ + int i,j,k,nc,ft; + unsigned long maxunsint,dvd,pqt,pp; + float nqt; + unsigned SHORT copa[10],copb[10],af[10],ppt[10],ppd[10],pqa[2]; + +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(double)BITSPERUI)-1; +#endif + + + for(j=0;j<10;j++) + { + af[j]=copa[j]=copb[j]=0; + } + for(j=0;j=0;i--) + { + dvd=(long)copa[nc]*(maxunsint+1)+(long)copa[nc-1]; + pqt=dvd/copb[n-1]; + pqa[1]=(unsigned SHORT)(pqt>>16); + pqa[0]=(unsigned SHORT)(pqt&maxunsint); + for(j=0;j<10;j++) + { + ppd[j]=((j>n-1)?0:copb[j]); + } + for(j=1;j<=i;j++) + { + for(k=9;k>=1;k--) + { + ppd[k]=ppd[k-1]; + } + ppd[0]=0; + } + _MulUnsArrByUnsArr(ppd,pqa,ppt,10,2,ft); + if (_CompareUnsArr(copa,ppt,nc+1)==-1) + { + pp=(long)ppt[nc]*(maxunsint+1)+(long)ppt[nc-1]; + nqt=(float)dvd; + nqt/=(float)pp; + nqt*=(float)pqt; + nqt+=(float)5; +#ifndef SH_LIB + pqa[1]=(unsigned SHORT)((long int)nqt>>16); + pqa[0]=(unsigned SHORT)((long int)nqt&maxunsint); +#endif + _MulUnsArrByUnsArr(ppd,pqa,ppt,10,2,ft); + } + while (_CompareUnsArr(copa,ppt,nc+1)==-1) + { + _SubUnsArr(pqa,af,2); + _MulUnsArrByUnsArr(ppd,pqa,ppt,10,2,ft); + } + c[i]=pqa[0]; + _SubUnsArr(copa,ppt,m); + nc--; + } + + /* qui copa Š = al resto della divisione!! */ + + if (rf) + { + _SubUnsArr(copb,af,n); + _HalveUnsArr(copb,n); + if (_CompareUnsArr(copa,copb,m)==1) + { + _IncrementUnsArr(c); + } + } +} + + diff --git a/gfm/dmbyp10.asm b/gfm/dmbyp10.asm new file mode 100755 index 000000000..9aedfdf0a --- /dev/null +++ b/gfm/dmbyp10.asm @@ -0,0 +1,190 @@ + ; int _DivUnsArrByPwrOf10(a, n, p) + ; + ; ARGUMENT + ; unsigned a[] n-word number to divide + ; int n number of digits + ; int p power of 10 to divide by + ; + ; DESCRIPTION + ; Divides a n-word 'a' by a power of 10, c = a / 10^p, + ; a>=0, p>0, rounding the result. c is correct only if a / 10^p < 2^79. + ; + ; SIDE EFFECTS + ; The value of a is destroyed (it isn't needed later). + ; + ; RETURNS + ; None. (always succeeds) + ; + ; AUTHOR + ; Jared Levy 7/9/89 + ; Copyright (C) 1989-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; + ; + ; + include model.h + include prologue.h + include gm.equ + + dseg dmbyp10 +p10 dw 1d,10d,100d,1000d,10000d + endds + + pseg dmbyp10 + cproc _DivUnsArrByPwrOf10,,_dmbyp10 + +; load parameters + +if _LDATA + mov ax, parm4_ ; get power of 10 to divide by +else + mov ax, parm3_ ; get power of 10 to divide by +endif + + cmp ax, 0 ; if dividing by 10^0=1, + je qexit ; nothing need be done + +if _LDATA + push es + les di, parm1_ ; get pointer to source & destination + mov bx, parm3_ ; get number of digits +else + mov di, parm1_ ; get pointer to source & destination + mov dx, ds + mov es, dx + mov bx, parm2_ ; get number of digits +endif + + cmp ax, 4 ; Is the division by less than 10^4? + jle less4d + +d10000: + mov cx, 10000d ; divide by 10000=10^4 +d4loop: + push ax ; save ax & bx + push bx + call near ptr dmby1a3 ; division + pop bx ; restore ax & bx + pop ax + sub ax, 4 ; 4 less powers of 10 to divide by + cmp ax, 4 ; are there 4 more left to do? + jg d4loop ; yes, do it again + +less4d: + mov si, ax + sal si, 1 + mov cx, p10[si] ; load correct power of ten + call near ptr dmby1ra3 ; division, with rounding + +if _LDATA + pop es +endif +qexit: + cproce + +dmby1a3: + dec bx ; digits go from 0 to n-1 + sal bx, 1 ; want bytes rather than words + +;/* skip initial zeroes */ +; for(;(q>0)&&(c[q-1]==0);q--); +; +; if (q == 0) +; return(0); +; q--; /* q will be used for subscript */ +zeroloop: + mov ax, word ptr es:[di+bx] ; get digit + cmp ax, 0 ; is digit zero? + jne nonzero ; if non-zero, begin divide + dec bx ; next word + dec bx + cmp bx, 0 ; last digit? + jge zeroloop ; if not, process next digit + xor ax, ax ; otherwise, remainder 0 + jmp short exit1 ; && division through (0/c=0) + +; bl = (unsigned long) b; +; while (q>=0) { +; k = (unsigned long *) &r[q]; +; cl = *k / bl; +; c[q] = (unsigned) cl; +; r[q] = (unsigned) (*k - cl * bl); +; q--; +; } +nonzero: + xor dx,dx ; high word zero in first divide +divloop: + div cx ; divide digit + mov word ptr es:[di+bx], ax ; store quotient digit + cmp bx, 0 ; last digit? + je exit2 ; if so, division complete + dec bx ; next digit + dec bx + mov ax, word ptr es:[di+bx] ; get digit + jmp short divloop ; process digit + +exit2: + mov ax, dx ; return remainder +exit1: + ret + +dmby1ra3: + dec bx ; digits go from 0 to n-1 + sal bx, 1 ; want bytes rather than words + +;/* skip initial zeroes */ +; for(;(q>0)&&(c[q-1]==0);q--); +; +; if (q == 0) +; return(0); +; q--; /* q will be used for subscript */ +rzeroloop: + mov ax, word ptr es:[di+bx] ; get digit + cmp ax, 0 ; is digit zero? + jne rnonzero ; if non-zero, begin divide + dec bx ; next word + dec bx + cmp bx, 0 ; last digit? + jge rzeroloop ; if not, process next digit +; xor ax, ax ; otherwise, remainder 0 + jmp short rexit1 ; && division through (0/c=0) + +; bl = (unsigned long) b; +; while (q>=0) { +; k = (unsigned long *) &r[q]; +; cl = *k / bl; +; c[q] = (unsigned) cl; +; r[q] = (unsigned) (*k - cl * bl); +; q--; +; } +rnonzero: + xor dx,dx ; high word zero in first divide +rdivloop: + div cx ; divide digit + mov word ptr es:[di+bx], ax ; store quotient digit + cmp bx, 0 ; last digit? + je rexit2 ; if so, division complete + dec bx ; next digit + dec bx + mov ax, word ptr es:[di+bx] ; get digit + jmp short rdivloop ; process digit + +; round up if remainder > (divisor-1)/2 +rexit2: + dec cx ; set cx = (cx-1)/2 + sar cx, 1 + cmp dx, cx ; test for rounding up + ja inclp ; if remainder is large, round up + ret +inclp: + inc word ptr es:[di] + jnz rexit1 + inc di + inc di + jmp short inclp + +rexit1: + ret + endps + end diff --git a/gfm/dmbyp10.c b/gfm/dmbyp10.c new file mode 100755 index 000000000..e0af4e9e2 --- /dev/null +++ b/gfm/dmbyp10.c @@ -0,0 +1,50 @@ +/* int _DivUnsArrByPwrOf10(a,n,p) + * + * ARGUMENT + * unsigned a[]; + * int p; power of 10 to divide by + * int n; number of digits + * + * DESCRIPTION + * Divides a number of n words (a) by a power of 10, c= a/10^p, + * a>=0, p>0, rounding the result, c is correct only if a/10^p<2^79. + * + * SIDE EFFECTS + * The value of a is destroyed. + * + * RETURNS + * None. (always succeeds) + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + + +void _DivUnsArrByPwrOf10(a,n,p) +unsigned SHORT a[]; +int n,p; +{ +int ppdf,i; + while (p>4) + { + _DivUnsArrByUns(a,10000,n); + p-=4; + } +#ifdef SH_LIB + ppdf=1; + for (i=1;i<=p;i++) ppdf*=10; +#else + ppdf=(int)pow(10.,(double)p); +#endif + _DivUnsArrByUnsRound(a,ppdf,n); +} diff --git a/gfm/dmbyp10t.asm b/gfm/dmbyp10t.asm new file mode 100755 index 000000000..ad3e2793b --- /dev/null +++ b/gfm/dmbyp10t.asm @@ -0,0 +1,134 @@ + ; int _DivUnsArrByPwrOf10Trunc(a, n, p) + ; + ; ARGUMENT + ; unsigned a[] n-word number to divide + ; int n number of digits + ; int p power of 10 to divide by + ; + ; DESCRIPTION + ; Divides a n-word 'a' by a power of 10, c = a / 10^p, + ; a>=0, p>0, truncating the result. c is correct only if a / 10^p < 2^79. + ; + ; SIDE EFFECTS + ; The value of a is destroyed (it isn't needed later). + ; + ; RETURNS + ; None. (always succeeds) + ; + ; AUTHOR + ; Jared Levy 7/9/89 + ; Copyright (C) 1989-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; + ; + ; + include model.h + include prologue.h + include gm.equ + + dseg dmbp10t +p10 dw 1d,10d,100d,1000d,10000d + endds + + pseg dmbp10t + cproc _DivUnsArrByPwrOf10Trunc,,_dmbp10t + +; load parameters + +if _LDATA + mov ax, parm4_ ; get power of 10 to divide by +else + mov ax, parm3_ ; get power of 10 to divide by +endif + + cmp ax, 0 ; if dividing by 10^0=1, + je qexit ; nothing need be done + +if _LDATA + push es + les di, parm1_ ; get pointer to source & destination + mov bx, parm3_ ; get number of digits +else + mov di, parm1_ ; get pointer to source & destination + mov dx, ds + mov es, dx + mov bx, parm2_ ; get number of digits +endif + + cmp ax, 4 ; Is the division by less than 10^4? + jle less4d + +d10000: + mov cx, 10000d ; divide by 10000=10^4 +d4loop: + push ax ; save ax & bx + push bx + call near ptr dmby1a2 ; division + pop bx ; restore ax & bx + pop ax + sub ax, 4 ; 4 less powers of 10 to divide by + cmp ax, 4 ; are there 4 more left to do? + jg d4loop ; yes, do it again + +less4d: + mov si, ax + sal si, 1 + mov cx, p10[si] ; load correct power of ten + call near ptr dmby1a2 ; division + +if _LDATA + pop es +endif +qexit: + cproce + +; the computation routine is separate so it may be called from assembly +dmby1a2: + dec bx ; digits go from 0 to n-1 + sal bx, 1 ; want bytes rather than words + +;/* skip initial zeroes */ +; for(;(q>0)&&(c[q-1]==0);q--); +; +; if (q == 0) +; return(0); +; q--; /* q will be used for subscript */ +zeroloop: + mov ax, word ptr es:[di+bx] ; get digit + cmp ax, 0 ; is digit zero? + jne nonzero ; if non-zero, begin divide + dec bx ; next word + dec bx + cmp bx, 0 ; last digit? + jge zeroloop ; if not, process next digit + xor ax, ax ; otherwise, remainder 0 + jmp short exit1 ; && division through (0/c=0) + +; bl = (unsigned long) b; +; while (q>=0) { +; k = (unsigned long *) &r[q]; +; cl = *k / bl; +; c[q] = (unsigned) cl; +; r[q] = (unsigned) (*k - cl * bl); +; q--; +; } +nonzero: + xor dx,dx ; high word zero in first divide +divloop: + div cx ; divide digit + mov word ptr es:[di+bx], ax ; store quotient digit + cmp bx, 0 ; last digit? + je exit2 ; if so, division complete + dec bx ; next digit + dec bx + mov ax, word ptr es:[di+bx] ; get digit + jmp short divloop ; process digit + +exit2: + mov ax, dx ; return remainder +exit1: + ret + + endps + end diff --git a/gfm/dmbyp10t.c b/gfm/dmbyp10t.c new file mode 100755 index 000000000..03dd46ff4 --- /dev/null +++ b/gfm/dmbyp10t.c @@ -0,0 +1,53 @@ +/* int _DivUnsArrByPwrOf10(a,n,p) + * + * ARGUMENT + * unsigned a[]; + * int p; power of 10 to divide by + * int n; number of digits + * + * DESCRIPTION + * Divides a number of n words (a) by a power of 10, c= a/10^p, + * a>=0, p>0, truncating the result, c is correct only if a/10^p<2^79. + * + * SIDE EFFECTS + * The value of a is destroyed. + * + * RETURNS + * None. (always succeeds) + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + + +void _DivUnsArrByPwrOf10Trunc(a,n,p) +unsigned SHORT a[]; +int n,p; +{ +int ppdf,i; + + while (p>4) + { + _DivUnsArrByUns(a,10000,n); + p-=4; + } + +#ifdef SH_LIB + ppdf=1; + for (i=1;i<=p;i++) ppdf*=10; +#else + ppdf=(int)pow(10.,(double)p); +#endif + _DivUnsArrByUns(a,ppdf,n); + +} diff --git a/gfm/dmbyp10tc.c b/gfm/dmbyp10tc.c new file mode 100755 index 000000000..03dd46ff4 --- /dev/null +++ b/gfm/dmbyp10tc.c @@ -0,0 +1,53 @@ +/* int _DivUnsArrByPwrOf10(a,n,p) + * + * ARGUMENT + * unsigned a[]; + * int p; power of 10 to divide by + * int n; number of digits + * + * DESCRIPTION + * Divides a number of n words (a) by a power of 10, c= a/10^p, + * a>=0, p>0, truncating the result, c is correct only if a/10^p<2^79. + * + * SIDE EFFECTS + * The value of a is destroyed. + * + * RETURNS + * None. (always succeeds) + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + + +void _DivUnsArrByPwrOf10Trunc(a,n,p) +unsigned SHORT a[]; +int n,p; +{ +int ppdf,i; + + while (p>4) + { + _DivUnsArrByUns(a,10000,n); + p-=4; + } + +#ifdef SH_LIB + ppdf=1; + for (i=1;i<=p;i++) ppdf*=10; +#else + ppdf=(int)pow(10.,(double)p); +#endif + _DivUnsArrByUns(a,ppdf,n); + +} diff --git a/gfm/dmean.c b/gfm/dmean.c new file mode 100755 index 000000000..bef7b508b --- /dev/null +++ b/gfm/dmean.c @@ -0,0 +1,77 @@ +/* DEC *StatMean(pDst,pSrc,n) + * + * ARGUMENT + * DEC *pDst; + * DEC **pSrc; + * int n; + * + * DESCRIPTION + * Sets pDst to the mean of the n DEC elements of the array pSrc. + * n <= 0 is not allowed. pDst is unchanged if an error occurs. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to the average if successful, otherwise + * returns GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_ARGVAL + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *StatMean(pDst,pSrc,n) +DEC *pDst; +DEC **pSrc; +int n; +{ + int i; + DEC *p, dsum, *sum=&dsum, ddn, *dn=&ddn; + +/* source must be supplied !! */ + _MacStart(GM_DMEAN); + + if (!pSrc) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + + if (n<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + for (i=0; i +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + +void _DoubleUnsArr(a,n) +unsigned SHORT a[]; +int n; +{ + int i; + unsigned long maxunsint,pdst; + unsigned SHORT carry; + + carry=0; +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1; +#endif + if (n>0) + { + for (i=0;imaxunsint) + { + carry=(unsigned SHORT)(pdst>> BITSPERUI ); + a[i]=(unsigned SHORT)(pdst & maxunsint ); + } + else + { + a[i]=(unsigned SHORT)pdst; + carry=0; + } + } + if ((a[n-1])>>(BITSPERUI-1)) + { + return(FAILURE); + } + else + { + return(GM_SUCCESS); + } + } +} diff --git a/gfm/dmin.c b/gfm/dmin.c new file mode 100755 index 000000000..fa27c0215 --- /dev/null +++ b/gfm/dmin.c @@ -0,0 +1,53 @@ +/* DEC *MinimumDecimal(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pSrc1,*pSrc2,*pDst; + * + * DESCRIPTION + * Returns the smaller of pSrc1 and pSrc2 in pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to pDst if successful + * otherwise GM_NULL and sets the global error to GM_NULLPOINTER. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * AA 17-Sep-87 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MinimumDecimal(pDst,pSrc1,pSrc2) +DEC *pSrc1,*pSrc2,*pDst; +{ + + int i; + + _MacStart(GM_DMIN); + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + _MacOutVarD(pDst); + + i = CompareDecimal(pSrc1,pSrc2); + + if(i>0) + _MacDCopy(pDst,pSrc2); + else + _MacDCopy(pDst,pSrc1); + + _MacRet(pDst); +} + diff --git a/gfm/dmod.c b/gfm/dmod.c new file mode 100755 index 000000000..ec3d9c1bc --- /dev/null +++ b/gfm/dmod.c @@ -0,0 +1,69 @@ +/* DEC *ModuloDecimal(pDst, pSrc1, pSrc2); + * + * ARGUMENT + * DEC *pDst, *pSrc1, *pSrc2; + * + * DESCRIPTION + * Sets pDst = pSrc1 mod pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_DIV0 (if pSrc2 == 0) + * + * ALGORITHM + * a mod b = a - int(a / b) * b + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ModuloDecimal(pDst, pSrc1, pSrc2) +DEC *pDst, *pSrc1, *pSrc2; +{ + DEC dquot, *quot=&dquot, dprod, *prod=&dprod; + int i; + + _MacStart(GM_DMOD); + + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + _MacOutVarD(pDst); + + if (_MacIsDecZ(pSrc2)) { + _MacErr(GM_DIV0); + _MacRet(GM_NULL); + } + + i = _DivTrnDec80Bit(quot, pSrc1, pSrc2, 0); + +/* overflow here indicates pSrc1 mod pSrc2 = 0 */ + if (i == GM_OVERFLOW) { + _MacDZero(pDst); + pDst->dc.id = pSrc1->dc.id; + _MacRet(pDst); + } + +/* overflow not possible here since |prod| <= |pSrc1| */ + (void) _MulDec80Bit(prod, quot, pSrc2); + (void) _Sq5UnsTo4Uns(prod); + +/* result must be 64 bits since |prod| <= |pSrc1| */ + (void) _SubDec80Bit(pDst, pSrc1, prod); + + _MacRet(pDst); +} diff --git a/gfm/dmoddf.c b/gfm/dmoddf.c new file mode 100755 index 000000000..70499691d --- /dev/null +++ b/gfm/dmoddf.c @@ -0,0 +1,54 @@ +/* DEC *DecimalModuloDouble(pDst, pSrc1, pSrc2); + * + * ARGUMENT + * DEC *pDst, *pSrc1; + * double pSrc2; + * + * DESCRIPTION + * Sets pDst = pSrc1 mod pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_DIV0 (if pSrc2 == 0) + * GM_CNVRE + * + * ALGORITHM + * a mod b = a - int(a / b) * b + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DecimalModuloDouble(pDst, pSrc1, pSrc2) +DEC *pDst, *pSrc1; +double pSrc2; +{ + DEC dt2, *t2=&dt2, *pd; + + _MacStart(GM_DMODDF); + + t2 = ConvDoubleToDecimal(t2, pSrc2); + if (!t2) { + if (pDst) + _MacDCopy(pDst, pSrc1); + _MacRet(GM_NULL); + } + + pd = ModuloDecimal(pDst, pSrc1, t2); + _MacRet(pd); +} diff --git a/gfm/dmodi.c b/gfm/dmodi.c new file mode 100755 index 000000000..a4b348651 --- /dev/null +++ b/gfm/dmodi.c @@ -0,0 +1,45 @@ +/* DEC *DecimalModuloInt(pDst, pSrc1, pSrc2); + * + * ARGUMENT + * DEC *pDst, *pSrc1; + * int pSrc2; + * + * DESCRIPTION + * Sets pDst = pSrc1 mod pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_NOMEMORY + * GM_DIV0 (if pSrc2 == 0) + * + * ALGORITHM + * a mod b = a - int(a / b) * b + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DecimalModuloInt(pDst, pSrc1, pSrc2) +DEC *pDst, *pSrc1; +int pSrc2; +{ + _MacStart(GM_DMODI); + + pDst = DecimalModuloLong(pDst, pSrc1, (long) pSrc2); + _MacRet(pDst); +} diff --git a/gfm/dmodl.c b/gfm/dmodl.c new file mode 100755 index 000000000..75890ba42 --- /dev/null +++ b/gfm/dmodl.c @@ -0,0 +1,48 @@ +/* DEC *DecimalModuloLong(pDst, pSrc1, pSrc2); + * + * ARGUMENT + * DEC *pDst, *pSrc1; + * long pSrc2; + * + * DESCRIPTION + * Sets pDst = pSrc1 mod pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_DIV0 (if pSrc2 == 0) + * + * ALGORITHM + * a mod b = a - int(a / b) * b + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DecimalModuloLong(pDst, pSrc1, pSrc2) +DEC *pDst, *pSrc1; +long pSrc2; +{ + DEC dt2, *t2=&dt2, *pd; + + _MacStart(GM_DMODL); + + (void) ConvLongToDecimal(t2, pSrc2); + + pd = ModuloDecimal(pDst, pSrc1, t2); + _MacRet(pd); +} diff --git a/gfm/dmodui.c b/gfm/dmodui.c new file mode 100755 index 000000000..6b4e2b8cf --- /dev/null +++ b/gfm/dmodui.c @@ -0,0 +1,44 @@ +/* DEC *DecimalModuloUns(pDst, pSrc1, pSrc2); + * + * ARGUMENT + * DEC *pDst, *pSrc1; + * unsigned pSrc2; + * + * DESCRIPTION + * Sets pDst = pSrc1 mod pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_DIV0 (if pSrc2 == 0) + * + * ALGORITHM + * a mod b = a - int(a / b) * b + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DecimalModuloUns(pDst, pSrc1, pSrc2) +DEC *pDst, *pSrc1; +unsigned int pSrc2; +{ + _MacStart(GM_DMODUI); + + pDst = DecimalModuloLong(pDst, pSrc1, (long) pSrc2); + _MacRet(pDst); +} diff --git a/gfm/dmodul.c b/gfm/dmodul.c new file mode 100755 index 000000000..5ec4d89c8 --- /dev/null +++ b/gfm/dmodul.c @@ -0,0 +1,48 @@ +/* DEC *DecimalModuloUnsLong(pDst, pSrc1, pSrc2); + * + * ARGUMENT + * DEC *pDst, *pSrc1; + * unsigned long pSrc2; + * + * DESCRIPTION + * Sets pDst = pSrc1 mod pSrc2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_DIV0 (if pSrc2 == 0) + * + * ALGORITHM + * a mod b = a - int(a / b) * b + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DecimalModuloUnsLong(pDst, pSrc1, pSrc2) +DEC *pDst, *pSrc1; +unsigned long pSrc2; +{ + DEC dt2, *t2=&dt2, *pd; + + _MacStart(GM_DMODI); + + (void) ConvUnsLongToDecimal(t2, pSrc2); + + pd = ModuloDecimal(pDst, pSrc1, t2); + _MacRet(pd); +} diff --git a/gfm/dmul.c b/gfm/dmul.c new file mode 100755 index 000000000..2527744c4 --- /dev/null +++ b/gfm/dmul.c @@ -0,0 +1,129 @@ +/* DEC *MultiplyDecimal(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * + * DESCRIPTION + * Multiplies pSrc1 times pSrc2 and puts it into pDst. + * pSrc1 and pSrc2 remain unchanged. + * Additionally, if either number is negative, it + * is temporarily converted a positive for the mult. and a flag is set + * to convert the answer if unlike signs. + * + * SIDE EFFECTS + * pDst is indeterminate on error. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Andy Anderson 29-JAN-1987 16:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MultiplyDecimal(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + register int i,p; + int r=0,stktmp=0; + unsigned SHORT dtp[10]; + + + _MacStart(GM_DMUL); + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + _MacOutVarD(pDst); + +/* First, if either of the numbers is zero, the result is alway zero */ + if((_MacIsDecZ(pSrc1)) || (_MacIsDecZ(pSrc2))) { + i = pSrc1->dc.id + pSrc2->dc.id; + _MacDZero(pDst); + pDst->dc.id = (i > GM_MAXID) ? GM_MAXID : i; + _MacRet(pDst); + } + +/* Find out number of 16-bit int's in each number */ + i = 3; + while ( pSrc1->dc.sl[i] ==0 && i>=0 ) + i--; + p = 3; + while ( pSrc2->dc.sl[p] == 0 && p>=0 ) + p--; + + + /* allow user to specify pDst as one of the sources */ + _MulUnsArrByUnsArr(pSrc1->dc.sl, pSrc2->dc.sl, dtp, + i+1,p+1,stktmp); + + /* squeeze eight digits down to four */ + p=0; + while ((dtp[4] >= 500) || (dtp[5] != 0) || + (dtp[6] != 0) || (dtp[7] != 0)) { + r = _DivUnsArrByUns(dtp, 10000, 8); + p+=4; + } + + if (!dtp[4] && dtp[3]<=32767) { + if (r>=5000) + (void) _IncrementUnsArr(dtp); + } + else + if (dtp[4] >= 50) { + _DivUnsArrByUnsRound(dtp, 1000, 5); + p+=3; + } + else + if (dtp[4] >= 5) { + _DivUnsArrByUnsRound(dtp, 100, 5); + p+=2; + } + else { + _DivUnsArrByUnsRound(dtp, 10, 5); + p++; + } +/* now p is the power of 10 which was divided */ + + i = pSrc1->dc.id + pSrc2->dc.id - p; + if (i < GM_MINID) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + pDst->dc.sl[0] = dtp[0]; + pDst->dc.sl[1] = dtp[1]; + pDst->dc.sl[2] = dtp[2]; + pDst->dc.sl[3] = dtp[3]; + pDst->dc.sl[4] = dtp[4]; + +/* if the signs of the sources are different, pDst=-pDst */ + pDst->dc.attr = (pSrc1->dc.attr^pSrc2->dc.attr); + + if (i > GM_MAXID) { + _DivUnsArrByPwrOf10(pDst->dc.sl, + 4, i - GM_MAXID); + pDst->dc.id = GM_MAXID; + if (_MacIsDecZ(pDst)) + _MacErr(GM_UNDERFLOW); + } + + pDst->dc.id = i; + + _MacRet(pDst); +} diff --git a/gfm/dmulr.c b/gfm/dmulr.c new file mode 100755 index 000000000..f0e08d565 --- /dev/null +++ b/gfm/dmulr.c @@ -0,0 +1,76 @@ +/* DEC *MultiplyDecimalAndRound(pDst,pSrc1,pSrc2,nid); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * int nid; + * + * DESCRIPTION + * Multiplies pSrc1 by pSrc2, storing the result in pDst. The product is + * calculated to nid decimal places. + * + * SIDE EFFECTS + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError doesn't contain a previous error. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_INVALIDID + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MultiplyDecimalAndRound(pDst,pSrc1,pSrc2,nid) +DEC *pDst; +DEC *pSrc1,*pSrc2; +int nid; +{ + register int i; + + _MacStart(GM_DMULR); + + if ((nidGM_MAXID)) { + _MacErr(GM_INVALIDID); + _MacRet(GM_NULL); + } + + if (!MultiplyDecimal(pDst, pSrc1, pSrc2)) + _MacRet(GM_NULL); + + if (_MacIsDecZ(pDst)) { + pDst->dc.id = nid; + _MacRet(pDst); + } + + i = _ScaleDec80Bit(pDst, pDst, nid); + +/* check if number can fit into 64 bits (no shifting allowed) */ + if (!((pDst->dc.msd == 0) && (pDst->dc.sl[3] < 32768L))) + i = GM_OVERFLOW; + + if (i != GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pDst)) + _MacErr(GM_UNDERFLOW); + + _MacRet(pDst); + +} diff --git a/gfm/dmult.c b/gfm/dmult.c new file mode 100755 index 000000000..d5a02454a --- /dev/null +++ b/gfm/dmult.c @@ -0,0 +1,78 @@ +/* DEC *MultiplyDecimalAndTruncate(pDst,pSrc1,pSrc2,nid); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * int nid; + * + * DESCRIPTION + * Multiplies pSrc1 by pSrc2, storing the result in pDst. The product is + * calculated to nid decimal places. + * + * SIDE EFFECTS + * *pDst is indeterminate on overflow, underflow. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError doesn't contain a previous error. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * GM_INVALIDID + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MultiplyDecimalAndTruncate(pDst,pSrc1,pSrc2,nid) +DEC *pDst; +DEC *pSrc1,*pSrc2; +int nid; +{ + register int i; + + _MacStart(GM_DMULT); + + if ((nidGM_MAXID)) { + _MacErr(GM_INVALIDID); + _MacRet(GM_NULL); + } + + if (!MultiplyDecimal(pDst, pSrc1, pSrc2)) + _MacRet(GM_NULL); + + if (_MacIsDecZ(pDst)) { + pDst->dc.id = nid; + _MacRet(pDst); + } + + i = _TruncateDec80Bit(pDst, pDst, nid); + +/* check if number can fit into 64 bits (no shifting allowed) */ + if (!((pDst->dc.msd == 0) && (pDst->dc.sl[3] < 32768L))) + i = GM_OVERFLOW; + + if (i != GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pDst)) + _MacErr(GM_UNDERFLOW); + + _MacRet(pDst); + +} diff --git a/gfm/dmux.c b/gfm/dmux.c new file mode 100755 index 000000000..ac9a2c6b2 --- /dev/null +++ b/gfm/dmux.c @@ -0,0 +1,112 @@ +/* int _MulDec80Bit(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1,pSrc2; + * + * DESCRIPTION + * Multiplies pSrc1 times pSrc2 and puts it into pDst. + * pSrc1 and pSrc2 remain unchanged. Note that we always make + * the number with the fewest non-zero 16-bit int's the multiplier for + * the low-level call. Additionally, if either number is negative, it + * is temporarily converted a positive for the mult. and a flag is set + * to convert the answer if unlike signs. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns GM_SUCCESS if successful, otherwise the error code. + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _MulDec80Bit(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + register int i,p; + int r=0,stktmp=0; + unsigned SHORT dtp[10]; + +/* First, if either of the numbers is zero, the result is alway zero */ + if((_MacIsDecZ(pSrc1)) || (_MacIsDecZ(pSrc2))) { + i = pSrc1->dc.id + pSrc2->dc.id; + _MacDZero(pDst); + pDst->dc.id = (i > GM_IMAXID) ? GM_IMAXID : i; + return(GM_SUCCESS); + } + +/* Find out number of 16-bit int's in each number */ + i = 4; + while ( pSrc1->dc.sl[i]==0 && i>=0) + i--; + p = 4; + while ( pSrc2->dc.sl[p]==0 && p>=0 ) + p--; + + + /* allow user to specify pDst as one of the sources */ + _MulUnsArrByUnsArr(pSrc1->dc.sl, pSrc2->dc.sl, dtp, + i+1,p+1,stktmp); + + /* squeeze eight digits down to four */ + p=0; + while ((dtp[4] >= 500) || (dtp[5] != 0) || (dtp[6] != 0) || + (dtp[7] != 0) || (dtp[8] != 0) || (dtp[9] != 0)) { + r = _DivUnsArrByUns(dtp, 10000, 10); + p+=4; + } + + if (!dtp[4] && dtp[3]<=32767) { + if (r>=5000) + (void) _IncrementUnsArr(dtp); + } + else + if (dtp[4] >= 50) { + _DivUnsArrByUnsRound(dtp, 1000, 5); + p+=3; + } + else + if (dtp[4] >= 5) { + _DivUnsArrByUnsRound(dtp, 100, 5); + p+=2; + } + else { + _DivUnsArrByUnsRound(dtp, 10, 5); + p++; + } +/* now p is the power of 10 which was divided */ + + i = pSrc1->dc.id + pSrc2->dc.id - p; + if (i < GM_IMINID) + return(GM_OVERFLOW); + pDst->dc.sl[0] = dtp[0]; + pDst->dc.sl[1] = dtp[1]; + pDst->dc.sl[2] = dtp[2]; + pDst->dc.sl[3] = dtp[3]; + pDst->dc.sl[4] = dtp[4]; + +/* if the signs of the sources are different, pDst=-pDst */ + pDst->dc.attr = (pSrc1->dc.attr^pSrc2->dc.attr); + + if (i > GM_IMAXID) { + _DivUnsArrByPwrOf10(pDst->dc.sl, + 5, i - GM_IMAXID); + pDst->dc.id = GM_IMAXID; + return((_MacIsDecZ(pDst))? GM_UNDERFLOW : GM_SUCCESS); + } + + pDst->dc.id = i; + + return(GM_SUCCESS); +} diff --git a/gfm/dpct.c b/gfm/dpct.c new file mode 100755 index 000000000..80bd72b59 --- /dev/null +++ b/gfm/dpct.c @@ -0,0 +1,101 @@ +/* int DecimalPercentage(pDst,src,opt); + * + * ARGUMENT + * DEC *pDst; dest + * DEC *src; source + * int opt; option + * + * DESCRIPTION + * According to the option opt, + * opt = 1 dst = src * 100 + * opt = 2 dst = src / 100 + * opt = 3 dst = src / 1200 + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns ptr to pDst if successful, else GM_NULL. + * + * POSSIBLE ERROR CODES: + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_ARGVAL + * + * AUTHOR + * Andy Anderson 20-Feb-87 16:35 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DecimalPercentage(pDst,src,opt) +DEC *pDst, *src; +int opt; +{ + + DEC dcons, *cons=&dcons; + + _MacStart(GM_DPCT); + _MacInVarD(src); + _MacOutVarD(pDst); + + if ((opt<1)||(opt>3)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + _MacOutVar(pDst,GM_NULL); + + if (_MacIsDecZ(src)) { + _MacDCopy(pDst,src); + _MacRet(pDst); + } + + if (opt==1) { + /* try to _MacRet the per cent */ + if(src->dc.id >= 2) { + _MacDCopy(pDst,src); + pDst->dc.id -= 2; + } + else { + (void) ConvLongToDecimal(cons, 100L); + if (!MultiplyDecimal(pDst,src,cons)) { + _MacRet(GM_NULL); + } + } + } + + if (opt == 2) { + _MacDCopy(pDst,src); + if (src->dc.id <= GM_MAXID-2) { + pDst->dc.id += 2; + } + else { + if (pDst->dc.id == GM_MAXID-1) { + pDst->dc.id++; + _DivUnsArrByUns( pDst->dc.sl, + 10, 5); + } + else + _DivUnsArrByUns( pDst->dc.sl, + 100, 5); + if (_MacIsDecZ(pDst)) + _MacErr(GM_UNDERFLOW); + } + } + + if (opt == 3) { + (void) ConvLongToDecimal(cons, 1200L); + (void) DivideDecimal(pDst, src, cons); + } + + _MacRet(pDst); +} diff --git a/gfm/dpdb.c b/gfm/dpdb.c new file mode 100755 index 000000000..35af46622 --- /dev/null +++ b/gfm/dpdb.c @@ -0,0 +1,121 @@ +/* DEC *DepreciateDeclining(depr, remval, book, salv,dbf,life,partial,time); + * + * ARGUMENT + * DEC *depr, *remval, *book, *salv, *dbf, *partial; + * int life, time; + * + * DESCRIPTION + * Calculate a specific year's depreciation and remaining depreciable + * value according to declining balance depreciation. + * With a declining balance factor of dbf, the item has book value + * book, salvage value salv, and lifetime life (which may include a partial + * period). At year# time, the depreciation and remaining value are + * computed and stored in depr and remval. The first year is always + * the partial year. + * + * SIDE EFFECTS + * depr and remval are changed. + * + * RETURNS + * depr if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DepreciateDeclining(depr, remval, book, salv,dbf,life, partial, time) +DEC *depr, *remval, *book, *salv, *dbf, *partial; +int life, time; +{ + int i, plife; + DEC drbv, *rbv=&drbv, dfol, *fol=&dfol; + DEC dtemp, *temp=&dtemp, dnsalv, *nsalv=&dnsalv; + + _MacStart(GM_DPDB); + + if (!depr||!remval||!book||!salv||!partial||!dbf) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + if (_MacBad(salv)||_MacBad(partial)||_MacBad(dbf)) { + _MacErr(GM_INIT); + _MacRet(GM_NULL); + } + + plife=life+(_MacIsDecZ(partial)?0:1); + + if (time<0||life<1||_MacIsDecN(book)||_MacIsDecN(salv)||time>plife + ||_MacIsDecN(dbf) + ||_MacIsDecN(partial)||CompareDecimal(partial,&decOne)==1) { + _MacDZero(depr); + _MacDZero(remval); + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + (void) _ScaleDec80Bit(rbv, book, 2); + (void) _ScaleDec80Bit(nsalv, salv, 2); + (void) _SubDec80Bit(remval, rbv, nsalv); + + if (time==0) { + _MacDZero(depr); + _MacRet(depr); + } + + (void) ConvLongToDecimal(temp, (long) life * 100L); + (void) _DivDec80Bit(fol, dbf, temp); + +/* handle partial first year */ + if (_MacIsDecZ(partial)) { + i=0; + } + else { + (void) _MulDec80Bit(temp,rbv,fol); + (void) _MulDec80Bit(depr, temp, partial); + (void) _ScaleDec80Bit(depr,depr,2); + (void) _SubDec80Bit(remval, remval, depr); +/* remaining value can't be negative */ + if (_MacIsDecN(remval)) { + (void) _AddDec80Bit(depr, depr, remval); + _MacDZero(remval); + } + (void) _SubDec80Bit(rbv, rbv, depr); + i=1; + } + +/* handle remaining years */ + + while (i +#include "gm.h" +#include "gmsystem.h" + +DEC **DepreciateDecliningTable(depr, remval, book, salv,dbf,life, partial) +DEC **depr, **remval, *book, *salv, *dbf, *partial; +int life; +{ + int i, plife; + DEC drbv, *rbv=&drbv, dfol, *fol=&dfol; + DEC dtemp, *temp=&dtemp, dnsalv, *nsalv=&dnsalv; + + _MacStart(GM_DPDBTBL); + + if (!depr||!remval||!book||!salv||!partial||!dbf) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + if (_MacBad(salv)||_MacBad(partial)||_MacBad(dbf)) { + _MacErr(GM_INIT); + _MacRet(GM_NULLARR); + } + + plife=life+(_MacIsDecZ(partial)?0:1); + + for (i=0;i<=plife;i++) + if(!depr[i]||!remval[i]) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + +/* check life>=1, 0<=partial<=1 */ + if (life<1||_MacIsDecN(partial)||CompareDecimal(partial,&decOne)==1 + ||_MacIsDecN(dbf) + ||_MacIsDecN(book)||_MacIsDecN(salv)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + + (void) _ScaleDec80Bit(rbv, book, 2); + (void) _ScaleDec80Bit(nsalv, salv, 2); + (void) _SubDec80Bit(remval[0],rbv,nsalv); + + _MacDZero(depr[0]); + + (void) ConvLongToDecimal(temp, (long) life * 100L); + (void) _DivDec80Bit(fol, dbf, temp); + +/* handle partial first year */ + if (_MacIsDecZ(partial)) { + i=0; + } + else { + (void) _MulDec80Bit(temp,rbv,fol); + (void) _MulDec80Bit(depr[1], temp, partial); + (void) _ScaleDec80Bit(depr[1],depr[1],2); + (void) _SubDec80Bit(remval[1], remval[0], depr[1]); +/* remaining value can't be negative */ + if (_MacIsDecN(remval[1])) { + (void) _AddDec80Bit(depr[1], depr[1], remval[1]); + _MacDZero(remval[1]); + } + (void) _SubDec80Bit(rbv,rbv,depr[1]); + i=1; + } + +/* handle remaining years */ + + while (i +#include "gm.h" +#include "gmsystem.h" + +DEC *DepreciateDoubleDeclining(depr,remval,book,salv,life,partial,time) +DEC *depr, *remval, *book, *salv, *partial; +int life, time; +{ + DEC dth, *th=&dth, *p; + + _MacStart(GM_DPDDB); + + (void) ConvLongToDecimal(th, 200L); + + p = DepreciateDeclining(depr,remval,book,salv,th,life,partial,time); + _MacRet(p); +} diff --git a/gfm/dpddbtbl.c b/gfm/dpddbtbl.c new file mode 100755 index 000000000..9d9610cef --- /dev/null +++ b/gfm/dpddbtbl.c @@ -0,0 +1,51 @@ +/* DEC **DepreciateDoubleDecliningTable(depr,remval,book,salv,life,partial); + * + * ARGUMENT + * DEC *depr, *remval, *book, *salv, *partial; + * int life; + * + * DESCRIPTION + * Calculate a specific year's depreciation and remaining depreciable + * value according to double declining balance depreciation. + * The item has book value + * book, salvage value salv, and lifetime life (which may include a partial + * period). At year# i, the depreciation and remaining value are + * computed and stored in depr[i] and remval[i]. The first year is always + * the partial year. + * + * SIDE EFFECTS + * depr and remval are changed. + * + * RETURNS + * depr if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC **DepreciateDoubleDecliningTable(depr,remval,book,salv,life,partial) +DEC **depr, **remval, *book, *salv, *partial; +int life; +{ + DEC dth, *th=&dth, **p; + + _MacStart(GM_DPDDBTBL); + + (void) ConvLongToDecimal(th, 200L); + + p = DepreciateDecliningTable(depr,remval,book,salv,th,life,partial); + _MacRet(p); +} diff --git a/gfm/dpow.c b/gfm/dpow.c new file mode 100755 index 000000000..c7f0ca78c --- /dev/null +++ b/gfm/dpow.c @@ -0,0 +1,110 @@ +/* DEC *PowerDecimal(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pDst,*pSrc1,*pSrc2; + * + * DESCRIPTION + * Calculates pSrc1 to the power pSrc2 and returns the answer in pDst. + * This provides an x**y power function for DEC numbers. Because of + * the way we store DEC numbers, the base can't be very large if the + * power is greater than 3 or 4. A separate function is provided for + * integral powers, which uses a different algorithm and is MUCH FASTER. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Pointer to the result if no error, otherwise GM_NULL. + * + * ALGORITHM: + * x**y = e**(y*ln(x)). Therefore, call dlnx() to get the natural log + * and then multiply by the power of x. Finally, call dexx() to provide + * e**z. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_IMAG + * GM_PWR0 + * + * AUTHOR + * Andy Anderson 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *PowerDecimal(pDst,pSrc1,pSrc2) +DEC *pDst, *pSrc1, *pSrc2; +{ + DEC temp, *pt; + int i; + + _MacStart(GM_DPOW); + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + _MacOutVarD(pDst); + + if (_MacIsDecN(pSrc1)) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pSrc1)) { + if (_MacIsDecP(pSrc2)) { + _MacDZero(pDst); + _MacRet(pDst); + } + else { + _MacErr(GM_PWR0); + _MacRet(GM_NULL); + } + } + + pt = &temp; + + /* if the power is integer and small enough, use int power rtn */ + if((pSrc2->dc.id == 0) && ((pSrc2->dc.msd == 0) && + (pSrc2->ls.lsl[1] == 0L) && (pSrc2->dc.sl[1] == 0)) + && (!(pSrc2->dc.sl[0] & 0x8000))) { + i = _IntPwrDec80Bit(pt,pSrc1,ConvDecimalToInt(pSrc2)); + if(i == GM_OVERFLOW) { + _MacErr(i); + _MacRet(GM_NULL); + } + } + else { + + (void) _LnDec80Bit(pt, pSrc1); + i = _MulDec80Bit(pt, pt, pSrc2); + if(i!=GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + i = _ExpDec80Bit(pt, pt); + if(i==GM_OVERFLOW) { + _MacErr(i); + _MacRet(GM_NULL); + } + } + + i = _Sq5UnsTo4Uns(pt); + if(i!=GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pt)) { + _MacErr(GM_UNDERFLOW); + } + + _MacDCopy(pDst,pt); + _MacRet(pDst); +} diff --git a/gfm/dpowi.c b/gfm/dpowi.c new file mode 100755 index 000000000..cefb6259e --- /dev/null +++ b/gfm/dpowi.c @@ -0,0 +1,82 @@ +/* DEC *PowerInteger(pDst,pSrc,i) + * + * ARGUMENT + * DEC *pDst,*pSrc; + * int i; + * + * DESCRIPTION + * Raises pSrc to the power 'i'. If i<0, raises pSrc to the |i|, then + * takes the reciprocal(ie, if i<0, then x**i = 1/x**|i|). If x=0, then + * if i=<0, then error (GM_NAN), else pDst is set to 1. If x<0, then if the + * power is odd, the result will be negative, otherwise positive. The + * absolute value cannot exceed 2**63 -1. Note we call dpoxi() because + * other high-level functions need returns of 2**79 -1, which is what + * this routine gets back and then sqeezes it back to 64-bits. + * + * SIDE EFFECTS + * *pDst is indeterminate on overflow, underflow. It is undisturbed + * on GM_NULLPOINTER. + * + * RETURNS + * Ptr to pDst if no errors, otherwise GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Andy Anderson 08-05-87 1130 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *PowerInteger(pDst,pSrc,i) +DEC *pDst,*pSrc; +int i; +{ + int wRetVal; + + _MacStart(GM_DPOWI); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + if (_MacIsDecZ(pSrc) && (i<=0)) { + _MacErr(GM_PWR0); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pSrc)) { + _MacDZero(pDst); + _MacRet(pDst); + } + + wRetVal=_IntPwrDec80Bit(pDst,pSrc,i); + + /* then see if success */ + if(wRetVal == GM_OVERFLOW) { + _MacErr(wRetVal); + _MacRet(GM_NULL); + } + + /* then try to reduce to 64-bit */ + wRetVal = _Sq5UnsTo4Uns(pDst); /* places or it's an error */ + + if(wRetVal != GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pDst)) { + _MacErr(GM_UNDERFLOW); + } + + _MacRet(pDst); +} diff --git a/gfm/dpowrat.c b/gfm/dpowrat.c new file mode 100755 index 000000000..940130a2a --- /dev/null +++ b/gfm/dpowrat.c @@ -0,0 +1,123 @@ +/* DEC *PowerRational(pDst,pSrc1,m,n) + * + * ARGUMENT + * DEC *pDst,*pSrc1; + * int m,n; + * + * DESCRIPTION + * Calculates pSrc1 to the power m/n and returns the answer in pDst. + * This provides an x**(m/n) power function for DEC numbers. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Pointer to the result if no error, otherwise GM_NULL. + * + * ALGORITHM: + * x**(m/n) = e**((m/n)*ln(x)). Therefore, call dlnx() to get the + * natural log + * and then multiply by the power of x. Finally, call dexx() to provide + * e**z. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_IMAG + * GM_PWR0 + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *PowerRational(pDst,pSrc,m,n) +DEC *pDst, *pSrc; +int m,n; +{ + DEC temp, *pt, *nsrc, dnsrc, ddm, *dm=&ddm; + int i, isn=0; + + _MacStart(GM_DPOWRAT); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + if (n == 0) { + _MacErr(GM_DIV0); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pSrc)) { + if (!((m<0)^(n<0))&&(m!=0)) { + _MacDZero(pDst); + _MacRet(pDst); + } + else { + _MacErr(GM_PWR0); + _MacRet(GM_NULL); + } + } + + if (m == 0) { + _MacDCopy(pDst,&decOne); + _MacRet(pDst); + } + + if (_MacIsDecN(pSrc)) { + while ((m % 2) + (n % 2) == 0) { + m=m/2; + n=n/2; + } + if ((n % 2) == 0) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + isn=m % 2; + nsrc = &dnsrc; + _MacDCopy(nsrc,pSrc); + pSrc=nsrc; + _MacDChgs(nsrc); + } + + pt = &temp; + + (void) _LnDec80Bit(pt, pSrc); + + (void) ConvLongToDecimal(dm, (long) m); + (void) _MulDec80Bit(pt, pt, dm); + + (void) ConvLongToDecimal(dm, (long) n); + (void) _DivDec80Bit(pt, pt, dm); + + i = _ExpDec80Bit(pt, pt); + if(i==GM_OVERFLOW) { + _MacErr(i); + _MacRet(GM_NULL); + } + + i = _Sq5UnsTo4Uns(pt); + if(i!=GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pt)) { + _MacErr(GM_UNDERFLOW); + } + + if (isn) + _MacDChgs(pt); + + _MacDCopy(pDst,pt); + _MacRet(pDst); +} diff --git a/gfm/dpoxi.c b/gfm/dpoxi.c new file mode 100755 index 000000000..789567959 --- /dev/null +++ b/gfm/dpoxi.c @@ -0,0 +1,134 @@ +/* int _IntPwrDec80Bit(pDst,pSrc,i) + * + * ARGUMENT + * DEC *pDst,*pSrc; + * int i; + * + * DESCRIPTION + * Raises pSrc to the power 'i'. If i<0, raises pSrc to the |i|, then + * takes the reciprocal(ie, if i<0, then x**i = 1/x**|i|). If x=0, then + * if i=<0, then error (GM_PWR0), else pDst is set to 1. If x<0, then if the + * power is odd, the result will be negative, otherwise positive. The + * absolute value cannot exceed 2**79 -1. Other high-level functions need + * returns of 2**79 -1, which is what this routine returns. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * GM_SUCCESS if no error, otherwise one of the errors below. Note that + * it is up to the caller to set any of these (with SetMathError()): + * GM_OVERFLOW if number is too large; + * GM_UNDERFLOW too small; or + * GM_PWR0 if power and base is as described above. + * + * AUTHOR + * Andy Anderson 08-10-87 0930 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _IntPwrDec80Bit(pDst,pSrc,i) +DEC *pDst,*pSrc; +int i; +{ + register int j; + int k; + mbool wfRecip, wfIsNeg, wfWasOdd; + DEC y,z,*py=&y,*pz=&z,*pone; + + j=i; + + /* constant of one for reciprocals */ + pone=&decOne; + _MacDCopy(py,pone); + + if(j==0) { + if(_MacIsDecP(pSrc)) { + _MacDCopy(pDst,pone); + return(GM_SUCCESS); + } + else + /* 0**0 and -x**0 are undefined */ + return(GM_PWR0); + } + + + /* then find out if final answer will be positive or negative */ + _MacDCopy(pz,pSrc); + if(_MacIsDecN(pSrc)) { + _MacDChgs(pz); + if(j&0x0001) + wfIsNeg=TRUE; /* negative number to odd exp = neg */ + else + wfIsNeg=FALSE; /* neg. number to even exp = pos */ + } + else { + wfIsNeg=FALSE; /* pos number to any exp = pos */ + } + + _MacDZero(pDst); + + /* then set do reciprocal bit */ + if(j<0) { + if ((long) j == -32768L) { +/* -32768 must be handled separately */ + k = _MulDec80Bit(pz, pz, pz); + if (k == GM_OVERFLOW) + return(GM_UNDERFLOW); + j = -16384; + } + wfRecip = TRUE; + j = -j; + } + else + wfRecip = FALSE; + + /* now do the calculation x ** i */ + do { + wfWasOdd = (j&0x0001) ? TRUE : FALSE; + j >>= 1; /* divide power by two */ + if(wfWasOdd) { + k=_MulDec80Bit(py,py,pz); + if(k!=GM_SUCCESS) + return(((k==GM_OVERFLOW)^wfRecip) ? + GM_OVERFLOW : GM_UNDERFLOW); + if(j==0) { + if(wfRecip) { + k=_DivDec80Bit(py,pone,py); + if(k!=GM_SUCCESS) + return(k); + } + if(wfIsNeg) + _MacDChgs(py); + _MacDCopy(pDst,py); + return(GM_SUCCESS); + } + k=_MulDec80Bit(pz,pz,pz); + if(k!=GM_SUCCESS) + return(((k==GM_OVERFLOW)^wfRecip) ? + GM_OVERFLOW : GM_UNDERFLOW); + } + else { + k=_MulDec80Bit(pz,pz,pz); /* z = z * z */ + if(k!=GM_SUCCESS) + return(((k==GM_OVERFLOW)^wfRecip) ? + GM_OVERFLOW : GM_UNDERFLOW); + } + } while(j>0); + + if(wfRecip) { + k=_DivDec80Bit(pz,pone,pz); + if(k!=GM_SUCCESS) + return(k); + } + if(wfIsNeg) + _MacDChgs(pz); + _MacDCopy(pDst,pz); + return(GM_SUCCESS); +} diff --git a/gfm/dprec.c b/gfm/dprec.c new file mode 100755 index 000000000..837c17b76 --- /dev/null +++ b/gfm/dprec.c @@ -0,0 +1,39 @@ +/* int DecimalPrecision(pSrc); + * + * ARGUMENT + * DEC *pSrc; + * + * DESCRIPTION + * Finds the number of digits past the decimal point of pSrc. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The number of digits past the decimal point, or GM_NULLPOINTER. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int DecimalPrecision(pSrc) +DEC *pSrc; +{ + _MacStart(GM_DPREC); + _MacInVarI(pSrc) + + _MacRet(pSrc->dc.id); +} diff --git a/gfm/dprintf.c b/gfm/dprintf.c new file mode 100755 index 000000000..607cd6ae0 --- /dev/null +++ b/gfm/dprintf.c @@ -0,0 +1,65 @@ +/* int PrintDecimal(fmt, arg,) + * + * ARGUMENT + * char *fmt; + * (?) arg; + * + * DESCRIPTION + * Prints out arguments, which may include DEC structures, according + * to the format string fmt. The function converts the DEC's to strings + * and calls printf. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The number of characters printed, the return from printf. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_INVALIDID + * GM_CNVRW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int PrintDecimal(fmt) +char *fmt; + +{ + char **outval, buffer[256]; + int i; + + _MacStart(GM_DPRINTF); + + if (!fmt) { + _MacErr(GM_NULLPOINTER); + _MacRet(0); + } + + outval = &fmt; +/* print the output */ + dsprintf(buffer, fmt, + outval[1], outval[2], outval[3], outval[4], outval[5], + outval[6], outval[7], outval[8], outval[9], outval[10] +#ifndef _LDATA + ,outval[11], outval[12], outval[13], outval[14], outval[15], + outval[16], outval[17], outval[18], outval[19], outval[20] +#endif + ); + + i = printf("%s", buffer); + + _MacRet(i); +} diff --git a/gfm/dpsl.c b/gfm/dpsl.c new file mode 100755 index 000000000..d5eddc1e1 --- /dev/null +++ b/gfm/dpsl.c @@ -0,0 +1,106 @@ +/* DEC *DepreciateStraightLine(depr, remval, book, salv, life, partial, time) + * + * ARGUMENT + * DEC *depr, *remval, *book, *salv, *partial; + * int time, life; + * + * DESCRIPTION + * Calculate a particular year's depreciation and remaining depreciable + * value according to straight line depreciation. The item has book value + * book, salvage value salv, and lifetime life (which may include a partial + * period). At year# time, the depreciation and remaining value are + * computed and stored in depr and remval. The first year is always the + * partial year. + * + * SIDE EFFECTS + * depr and remval are changed. + * + * RETURNS + * depr if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DepreciateStraightLine(depr, remval, book, salv, life, partial, time) +DEC *depr, *remval, *book, *salv, *partial; +int time, life; +{ + int i, plife; + DEC dtotlif, *totlif=&dtotlif; + DEC dydep, *ydep=&dydep; + + _MacStart(GM_DPSL); + + if (!depr||!remval||!book||!salv||!partial) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + if (_MacBad(book)||_MacBad(salv)||_MacBad(partial)) { + _MacErr(GM_INIT); + _MacRet(GM_NULL); + } + + plife = life + (_MacIsDecZ(partial)?0:1); + +/* check time>=0, life>=1, time<=life, 0<=partial<=1 */ + if (time<0||life<1||_MacIsDecN(book)||_MacIsDecN(salv)||time>plife + ||_MacIsDecN(partial)||CompareDecimal(partial,&decOne)==1) { + _MacDZero(depr); + _MacDZero(remval); + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + +/* calculate yearly depreciation */ + (void) _SubDec80Bit(remval,book,salv); + (void) _ScaleDec80Bit(remval, remval, 2); + (void) ConvLongToDecimal(totlif, (long) life); + (void) _DivRndDec80Bit(ydep, remval, totlif, 2); + + _MacDZero(depr); + + if (time==0) + _MacRet(depr); + +/* handle partial first year */ + if (_MacIsDecZ(partial)) { + i=0; + } + else { + (void) _MulDec80Bit(depr,ydep,partial); + (void) _ScaleDec80Bit(depr,depr,2); + (void) _SubDec80Bit(remval, remval, depr); + i=1; + } + +/* handle remaining years */ + if (time>i) + _MacDCopy(depr, ydep); + + while (i +#include "gm.h" +#include "gmsystem.h" + +DEC **DepreciateStraightLineTable(depr, remval, book, salv, life, partial) +DEC **depr, **remval, *book, *salv, *partial; +int life; +{ + int i, plife; + DEC dtotlif, *totlif=&dtotlif; + DEC dydep, *ydep=&dydep; + + _MacStart(GM_DPSLTBL); + + if (!depr||!remval||!book||!salv||!partial) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + if (_MacBad(book)||_MacBad(salv)||_MacBad(partial)) { + _MacErr(GM_INIT); + _MacRet(GM_NULLARR); + } + + plife=life+(_MacIsDecZ(partial)?0:1); + + for (i=0;i<=plife;i++) + if(!depr[i]||!remval[i]) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + +/* check life>=1, 0<=partial<=1 */ + if (life<1||_MacIsDecN(partial)||CompareDecimal(partial,&decOne)==1 + ||_MacIsDecN(book)||_MacIsDecN(salv)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* calculate yearly depreciation */ + (void) _SubDec80Bit(remval[0],book,salv); + (void) _ScaleDec80Bit(remval[0], remval[0], 2); + (void) ConvLongToDecimal(totlif, (long) life); + (void) _DivRndDec80Bit(ydep, remval[0], totlif, 2); + + _MacDZero(depr[0]); + +/* handle partial first year */ + if (_MacIsDecZ(partial)) { + i=0; + } + else { + (void) _MulDec80Bit(depr[1],ydep,partial); + (void) _ScaleDec80Bit(depr[1],depr[1],2); + (void) _SubDec80Bit(remval[1], remval[0], depr[1]); + i=1; + } + +/* handle remaining years */ + + while (i +#include "gm.h" +#include "gmsystem.h" + +DEC *DepreciateSumOfYears(depr, remval, book,salv,life,partial, time) +DEC *depr, *remval, *book, *salv, *partial; +int life, time; +{ + int i, plife; + DEC drbv0, *rbv0=&drbv0, dladj, *ladj=&dladj; + DEC ddlife, *dlife=&ddlife, dsoyd, *soyd=&dsoyd; + DEC dtemp, *temp=&dtemp, dtemp2, *temp2=&dtemp2; + + _MacStart(GM_DPSOYTBL); + + if (!depr||!remval||!book||!salv||!partial) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + if (_MacBad(book)||_MacBad(salv)||_MacBad(partial)) { + _MacErr(GM_INIT); + _MacRet(GM_NULL); + } + + plife=life+(_MacIsDecZ(partial)?0:1); + +/* check time>=0, life>=1, time<=life, 0<=partial<=1 */ + if (time<0||life<1||_MacIsDecN(book)||_MacIsDecN(salv)||time>plife + ||_MacIsDecN(partial)||CompareDecimal(partial,&decOne)==1) { + _MacDZero(depr); + _MacDZero(remval); + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + +/* calculate initial remaining book value & store zeroes indices */ + _MacDZero(depr); + (void) _SubDec80Bit(rbv0,book,salv); + (void) _ScaleDec80Bit(rbv0, rbv0, 2); + _MacDCopy(remval, rbv0); + + if (time==0) + _MacRet(depr); + +/* calculate sum of years digits soyd */ + (void) ConvLongToDecimal(soyd, + (long) (life) * (long) (life+1) / 2L); + + if (_MacIsDecZ(partial)) { + (void) ConvLongToDecimal(ladj, (long) life); + i=0; + } + else { + (void) ConvLongToDecimal(dlife, (long) life); +/* calculate first partial year's depreciation */ + (void) _MulDec80Bit(temp, dlife, partial); + (void) _MulDec80Bit(temp, temp, rbv0); + (void) _DivRndDec80Bit(depr, temp, soyd, 2); +/* subtract first depreciation from rbv */ + (void) _SubDec80Bit(rbv0, rbv0, depr); + _MacDCopy(remval,rbv0); + i=1; + +/* calculate sum of years digits soyd */ + (void) _SubDec80Bit(ladj, dlife, partial); + (void) _TruncateDec80Bit(temp, ladj, 0); + (void) _SubDec80Bit(temp2, ladj, temp); + (void) _AddDec80Bit(temp2, temp2, temp2); + (void) _AddDec80Bit(temp2, temp2, temp); + (void) _AddDec80Bit(temp, temp, &decOne); + (void) _MulDec80Bit(temp, temp, temp2); + (void) _MulDec80Bit(soyd, temp, &decPoint5); + + } + +/* handle remaining years */ + (void) _DivDec80Bit(temp, rbv0, soyd); + while (i +#include "gm.h" +#include "gmsystem.h" + +DEC **DepreciateSumOfYearsTable(depr, remval, book, salv, life, partial) +DEC **depr, **remval, *book, *salv, *partial; +int life; +{ + int i, plife; + DEC drbv0, *rbv0=&drbv0, dladj, *ladj=&dladj; + DEC ddlife, *dlife=&ddlife, dsoyd, *soyd=&dsoyd; + DEC dtemp, *temp=&dtemp, dtemp2, *temp2=&dtemp2; + + _MacStart(GM_DPSOYTBL); + + if (!depr||!remval||!book||!salv||!partial) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + if (_MacBad(book)||_MacBad(salv)||_MacBad(partial)) { + _MacErr(GM_INIT); + _MacRet(GM_NULLARR); + } + + plife=life+(_MacIsDecZ(partial)?0:1); + + for (i=0;i<=plife;i++) + if(!depr[i]||!remval[i]) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + +/* check life>=1, 0<=partial<=1 */ + if (life<1||_MacIsDecN(partial)||CompareDecimal(partial,&decOne)==1 + ||_MacIsDecN(book)||_MacIsDecN(salv)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* calculate initial remaining book value & store zeroes indices */ + _MacDZero(depr[0]); + (void) _SubDec80Bit(rbv0,book,salv); + (void) _ScaleDec80Bit(rbv0, rbv0, 2); + _MacDCopy(remval[0], rbv0); + +/* calculate sum of years digits soyd */ + (void) ConvLongToDecimal(soyd, + (long) (life) * (long) (life+1) / 2L); + + if (_MacIsDecZ(partial)) { + (void) ConvLongToDecimal(ladj, (long) life); + i=0; + } + else { + (void) ConvLongToDecimal(dlife, (long) life); +/* calculate first partial year's depreciation */ + (void) _MulDec80Bit(temp, dlife, partial); + (void) _MulDec80Bit(temp, temp, rbv0); + (void) _DivRndDec80Bit(depr[1], temp, soyd, 2); +/* subtract first depreciation from rbv */ + (void) _SubDec80Bit(rbv0, rbv0, depr[1]); + _MacDCopy(remval[1],rbv0); + i=1; + +/* calculate sum of years digits soyd */ + (void) _SubDec80Bit(ladj, dlife, partial); + (void) _TruncateDec80Bit(temp, ladj, 0); + (void) _SubDec80Bit(temp2, ladj, temp); + (void) _AddDec80Bit(temp2, temp2, temp2); + (void) _AddDec80Bit(temp2, temp2, temp); + (void) _AddDec80Bit(temp, temp, &decOne); + (void) _MulDec80Bit(temp, temp, temp2); + (void) _MulDec80Bit(soyd, temp, &decPoint5); + + } + +/* handle remaining years */ + (void) _DivDec80Bit(temp, rbv0, soyd); + while (i +#include "gmsystem.h" +DEC *ConvDegreesToRadians(rad, deg) +DEC *rad; +DEC *deg; +{ + _MacStart(GM_DRAD); + (void) _MulDec80Bit( rad, &decPiOver180, deg ); + (void) _Sq5UnsTo4Uns( rad ); + _MacRet( rad ); +} + diff --git a/gfm/droot.c b/gfm/droot.c new file mode 100755 index 000000000..f88a87461 --- /dev/null +++ b/gfm/droot.c @@ -0,0 +1,101 @@ +/* DEC *RootDecimal(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pDst,*pSrc1,*pSrc2; + * + * DESCRIPTION + * Calculates the pSrc2 root of pSrc1 and returns the answer in pDst. + * This provides an x**(1/y) power function for DEC numbers. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Pointer to the result if no error, otherwise GM_NULL. + * + * ALGORITHM: + * x**y = e**(ln(x)/y). Therefore, call dlnx() to get the natural log + * and then multiply by the power of x. Finally, call dexx() to provide + * e**z. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_IMAG + * GM_PWR0 + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *RootDecimal(pDst,pSrc1,pSrc2) +DEC *pDst, *pSrc1, *pSrc2; +{ + DEC temp, *pt; + int i; + + _MacStart(GM_DROOT); + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + _MacOutVarD(pDst); + + if (_MacIsDecN(pSrc1)) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pSrc2)) { + _MacErr(GM_DIV0); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pSrc1)) { + if (_MacIsDecP(pSrc2)) { + _MacDZero(pDst); + _MacRet(pDst); + } + else { + _MacErr(GM_PWR0); + _MacRet(GM_NULL); + } + } + + pt = &temp; + + (void) _LnDec80Bit(pt, pSrc1); + i = _DivDec80Bit(pt, pt, pSrc2); + if(i!=GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + + i = _ExpDec80Bit(pt, pt); + if(i==GM_OVERFLOW) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + i = _Sq5UnsTo4Uns(pt); + if(i!=GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pt)) { + _MacErr(GM_UNDERFLOW); + } + + _MacDCopy(pDst,pt); + _MacRet(pDst); +} diff --git a/gfm/drooti.c b/gfm/drooti.c new file mode 100755 index 000000000..43172c468 --- /dev/null +++ b/gfm/drooti.c @@ -0,0 +1,103 @@ +/* DEC *RootInteger(pDst,pSrc1,n) + * + * ARGUMENT + * DEC *pDst,*pSrc1; + * int n; + * + * DESCRIPTION + * Calculates the n'th root of pSrc1 and returns the answer in pDst. + * This provides an x**(1/n) power function for DEC numbers. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Pointer to the result if no error, otherwise GM_NULL. + * + * ALGORITHM: + * x**(1/n) = e**(ln(x)/n). + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_IMAG + * GM_PWR0 + * GM_DIV0 + * + * AUTHOR + * Andy Anderson 05-JAN-1987 17:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *RootInteger(pDst,pSrc,n) +DEC *pDst, *pSrc; +int n; +{ + DEC temp, *pt, *nsrc, dnsrc, ddn, *dn=&ddn; + int i, isn=0; + + _MacStart(GM_DROOTI); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + if (_MacIsDecZ(pSrc)) { + if (n>0) { + _MacDZero(pDst); + _MacRet(pDst); + } + else { + _MacErr(GM_PWR0); + _MacRet(GM_NULL); + } + } + + if (_MacIsDecN(pSrc)) { + if ((n % 2) == 0) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + isn=1; + nsrc = &dnsrc; + _MacDCopy(nsrc,pSrc); + pSrc=nsrc; + _MacDChgs(nsrc); + } + + pt = &temp; + + (void) _LnDec80Bit(pt, pSrc); + + (void) ConvLongToDecimal(dn, (long) n); + (void) _DivDec80Bit(pt, pt, dn); + + i = _ExpDec80Bit(pt, pt); + if(i==GM_OVERFLOW) { + _MacErr(i); + _MacRet(GM_NULL); + } + + i = _Sq5UnsTo4Uns(pt); + if(i!=GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pt)) { + _MacErr(GM_UNDERFLOW); + } + + if (isn) + _MacDChgs(pt); + + _MacDCopy(pDst,pt); + _MacRet(pDst); +} diff --git a/gfm/dround.c b/gfm/dround.c new file mode 100755 index 000000000..be9b0486e --- /dev/null +++ b/gfm/dround.c @@ -0,0 +1,78 @@ +/* DEC *RoundDecimal(pDst,pSrc1,wID) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * wID is the integer specifying location of implied decimal + * for the conversion. + * + * DESCRIPTION + * Adjusts the number in pSrc1 (if necessary) while copying it to + * pDst adjusting pDst to wID number of decimal places. If pDst is null + * on entry, tries to first create a pDst, then the conversion. When the + * number of decimal places decreases, the result is rounded off. + * + * SIDE EFFECTS + * pSrc1 remains unchanged and pDst is undefined on error. + * + * RETURNS + * Returns a pointer to the pDst structure unless error, + * in which case it returns a NULL(a C false). On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_INVALIDID + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy 5/28/87 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * +*/ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *RoundDecimal(pDst,pSrc1,wID) +DEC *pDst, *pSrc1; +int wID; +{ + int i; + + _MacStart(GM_DROUND); + _MacInVarD(pSrc1); + _MacOutVarD(pDst); + + if (wIDGM_MAXID) { + _MacErr(GM_INVALIDID); + _MacRet(GM_NULL); + } + + if(_MacIsDecZ(pSrc1)) { + _MacDZero(pDst); + pDst->dc.id = wID; + _MacRet(pDst); + } + + i = _ScaleDec80Bit(pDst, pSrc1, wID); + +/* check if number can fit into 64 bits (no shifting allowed) */ + if (!((pDst->dc.msd == 0) && (pDst->dc.sl[3] < 32768L))) + i = GM_OVERFLOW; + + if (i == GM_OVERFLOW) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pDst)) + _MacErr(GM_UNDERFLOW); + + _MacRet(pDst); +} diff --git a/gfm/dscanf.c b/gfm/dscanf.c new file mode 100755 index 000000000..798226b75 --- /dev/null +++ b/gfm/dscanf.c @@ -0,0 +1,62 @@ +/* int ScanDecimal(sFmt, arg,) + * + * ARGUMENT + * char *sFmt; + * (?) arg; + * + * DESCRIPTION + * Scans arguments, which may include DEC structures, + * from stdio, according + * to the format string sFmt. The function converts the DEC's to strings + * and calls scanf. + * + * SIDE EFFECTS + * The arguments are changed. + * + * RETURNS + * The number of fields scanned, the return from scanf. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_INVALIDID + * GM_CNVRW + * GM_CNVRE + * GM_NAN + * GM_EOF + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int ScanDecimal(sFmt) +char *sFmt; + +{ + int i; + char **pOutVal; + + _MacStart(GM_DSCANF); + + pOutVal=&sFmt; + + i=_ScanfAux(1, sFmt, sFmt, + pOutVal[1], pOutVal[2], pOutVal[3], pOutVal[4], pOutVal[5], + pOutVal[6], pOutVal[7], pOutVal[8], pOutVal[9], pOutVal[10] +#ifndef _LDATA + ,pOutVal[11], pOutVal[12], pOutVal[13], pOutVal[14], pOutVal[15], + pOutVal[16], pOutVal[17], pOutVal[18], pOutVal[19], pOutVal[20] +#endif + ); + _MacRet(i); +} + diff --git a/gfm/dsetertn.c b/gfm/dsetertn.c new file mode 100755 index 000000000..96139c465 --- /dev/null +++ b/gfm/dsetertn.c @@ -0,0 +1,50 @@ +/* void SetMathErrVector(pfn); + * + * ARGUMENT + * void (*pfn)(); + * + * DESCRIPTION + * Sets the internal error handler to point to routine pfn. If pfn is + * NULL on entry, then the default routine address is set. Note that the + * function SetMathError is #define-d in gm.h, and results in call to + * wherever the pointer pfnGMErrVector points to. The default handler + * just sets the global variables wGMError and wGMErrFunNum if wGMError is + * equal to GM_SUCCESS. + * + * SIDE EFFECTS + * If a NULL pointer is passed, the routine sets the default Mathlib + * pointer, and sets the errors wGMError and wGMErrFunNum. The requested + * [NULL] pointer is NOT SET. + * + * RETURNS + * None. + * + * POSSIBLE ERROR CODES + * + * None. + * + * AUTHOR + * Andy Anderson 9/15/87 1400 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void SetMathErrVector(pfn) +void ( *pfn )( int , int ); +{ + _MacStart(GM_DSETERTN); + if(!pfn) { + pfnGMErrVector = GMDefErrHandler; + } + else + pfnGMErrVector = pfn; + + _MacRetV; +} diff --git a/gfm/dsign.c b/gfm/dsign.c new file mode 100755 index 000000000..93e09c177 --- /dev/null +++ b/gfm/dsign.c @@ -0,0 +1,49 @@ +/* int TestSignDecimal(pSrc1); + * + * ARGUMENT + * DEC *pSrc1; + * + * DESCRIPTION + * Decides whether pSrc1 is positive, negative, or zero. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns 1 if scr1 is positive. + * 0 if pSrc1 is zero. + * -1 if scr1 is negative. + * Returns GM_NULLPOINTER if pSrc1 points to a null. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 27-JAN-1987 19:00 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int TestSignDecimal(pSrc1) +DEC *pSrc1; +{ + + _MacStart(GM_DSIGN); + _MacInVarI(pSrc1); + +/* keep checks in this order */ + if(_MacIsDecP(pSrc1)) /* means positive AND non-zero */ + _MacRet(1); + + if(_MacIsDecN(pSrc1)) /* negative bit set */ + _MacRet(-1); + + _MacRet(0); +} diff --git a/gfm/dsin.c b/gfm/dsin.c new file mode 100755 index 000000000..e34e7ae09 --- /dev/null +++ b/gfm/dsin.c @@ -0,0 +1,49 @@ +/* DEC *SineDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the sine of pSrc radians. + * + * SIDE EFFECTS + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy Oct 16, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *SineDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; +{ + DEC *temp, dtemp; + + _MacStart(GM_DSIN); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + /* sin(x) = cos(pi/2 - x) */ + temp = &dtemp; + (void) _SubDec80Bit(temp, &decPiOver2, pSrc); + _CosDec80Bit(pDst, temp); + + (void) _Sq5UnsTo4Uns(pDst); + + _MacRet(pDst); +} diff --git a/gfm/dsins.c b/gfm/dsins.c new file mode 100755 index 000000000..5d3c022ed --- /dev/null +++ b/gfm/dsins.c @@ -0,0 +1,57 @@ +/* void _SinDecSmall(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst, *pSrc; + * + * DESCRIPTION + * Sets pDst = sin(pSrc), where 0 <= pSrc < pi / 4. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * ALGORITHM + * Using the Taylor series, + * sin(x) = x - x^3/3! + x^5/5! - ... + * + * AUTHOR + * Jared Levy April 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _SinDecSmall(pDst,pSrc) +DEC *pDst, *pSrc; +{ + DEC *srcsq, dsrcsq, *term, dterm, *fact, dfact; + int i; + + srcsq = &dsrcsq; + (void) _MulDec80Bit(srcsq, pSrc, pSrc); + _MacDCopy(pDst, pSrc); + fact = ConvLongToDecimal(&dfact, 6L); + term = &dterm; + (void) _MulDec80Bit(term, srcsq, pSrc); + (void) _DivRndDec80Bit(term, term, fact, 23); + i = 3; + while (!(_MacIsDecZ(term))) { + if ((i % 4) == 1) + (void) _AddDec80Bit(pDst, pDst, term); + else + (void) _SubDec80Bit(pDst, pDst, term); + i+=2; + _MulDec80Bit(term, term, srcsq); + fact->dc.sl[0] = i * (i - 1); + _DivRndDec80Bit(term, term, fact, 23); + } + +} + diff --git a/gfm/dsort.c b/gfm/dsort.c new file mode 100755 index 000000000..0897a683d --- /dev/null +++ b/gfm/dsort.c @@ -0,0 +1,118 @@ +/* DEC **SortDecimal(dst, src, n, opt); + * + * ARGUMENT + * DEC **dst; + * DEC **src; + * int n; + * int opt; + * + * DESCRIPTION + * Sorts an array in increasing or decreasing order. The n elements + * of src are sorted and stored in dst. opt is GM_INC if the elements + * should be sorted in increasing order, and opt is GM_DEC is the elements + * should be sorted in decreasing order. + * A temporary copy of the array is allocated by this procedure. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * dst if successful, otherwise GM_NULL + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_INIT + * GM_NOMEMORY + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ +#include +#include +#include "gmsystem.h" + +#ifndef DOS +extern char *calloc(unsigned ,unsigned ); +#endif + +DEC **SortDecimalArray(dst, src, n, opt) +DEC **dst, **src; +int n, opt; +{ + DEC *tmpd, **tmpa, *p; + int i; + extern void qsort(char *, unsigned, unsigned, int (*)()); + + _MacStart(GM_DSORT); + + if (n<0|| (opt!=GM_INC && opt!=GM_DEC)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + + if (!src||!dst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n==0) + _MacRet(dst); + + for (i=0;i +#include +#include "gmsystem.h" + +static int _StackSize(char, char); + +int StringPrintDecimal(buffer,fmt) +char *buffer; +char *fmt; + +{ + char newfmt[256], lastcode, thiscode; + int *inval, outval[21]; + SHORT i,j,k,l, inarg, outarg, wNumStar, wStack; + mbool wfRegChar, wfDecChar, wfOld3Color; + DEC *pDec; +#ifdef _LDATA + long *pLong; +#endif + + _MacStart(GM_DSPRINTF); + + wfOld3Color = wfGM3Color; + + if (!fmt || !buffer) { + if (buffer) + buffer[0]='\0'; + wfGM3Color = FALSE; + _MacErr(GM_NULLSTRING); + wfGM3Color = wfOld3Color; + _MacRet(0); + } + + inval = (int *) &fmt; +/* int casting guarantees 16 bit word size regardless of model */ + inarg = sizeof(char *) / sizeof(int); + outarg = 0; + +/* trace through format string */ + i=0; + j=0; + + if (wfGM3Color) { + newfmt[j]=cGMCodeNon; + lastcode=cGMCodeNon; + j++; + } + + while (fmt[i]!='\0') { + if (fmt[i]!='%') { + if (wfGM3Color && (lastcode!=cGMCodeNon)) { + newfmt[j]=cGMCodeNon; + lastcode=cGMCodeNon; + j++; + } + newfmt[j]=fmt[i]; /* copy element */ + j++; + i++; + } + + else { + /* check for specification */ + wfRegChar=FALSE; + wfDecChar=FALSE; + wNumStar=0; + k=i; + do { + k++; + if (fmt[k]=='d'||fmt[k]=='u'|| + fmt[k]=='o'||fmt[k]=='x'|| + fmt[k]=='f'||fmt[k]=='e'|| + fmt[k]=='g'||fmt[k]=='c'|| + fmt[k]=='X'||fmt[k]=='E'|| + fmt[k]=='p'||fmt[k]=='G'|| +#ifdef LATTICE + fmt[k]=='P'|| +#else + fmt[k]=='i'||fmt[k]=='n'|| +#endif + fmt[k]=='s') + wfRegChar = TRUE; + + if (fmt[k]==cGMFmt ||fmt[k]==cGMFmtComma|| + fmt[k]==cGMFmtSci||fmt[k]==cGMFmtSciE || + fmt[k]==cGMFmtEng||fmt[k]==cGMFmtEngE) + wfDecChar = TRUE; + + if (fmt[k]=='*') + wNumStar++; + + } while (fmt[k]!='\0'&&!wfRegChar&& + !wfDecChar&&fmt[k]!='%'); + + if (wfRegChar) { /* regular C type */ + /* copy arguments into output list */ + /* find size of argument */ + wStack = _StackSize(fmt[k],fmt[k-1]); + /* each * requires an additional argument */ + for (l=0;l 0) { + wGMStar= inval[inarg]; + inarg++; + } + if (wNumStar > 1) { + wGMStar2= inval[inarg]; + inarg++; + } + + /* find DEC pointer */ +#ifdef _LDATA + pLong = (long *) &inval[inarg]; + pDec = (DEC *) *pLong; +#else + pDec = (DEC *) inval[inarg]; +#endif + + if (wfGM3Color) { + if (!pDec || _MacBad(pDec)) + thiscode = cGMCodeNon; + else if (_MacIsDecN(pDec)) + thiscode = cGMCodeNeg; + else + thiscode = cGMCodePos; + if (lastcode!=thiscode) { + newfmt[j]=thiscode; + lastcode=thiscode; + j++; + } + } + + /* convert to formatted ascii */ + wfGM3Color = FALSE; + _ConvDecimalToAsciiFormatted(&newfmt[j], + pDec, &fmt[i]); +/* + * Lattice C 6.0 says I should remove this line since it is redundant. + * It looks to me like they are right. + * + * wfOld3Color = wfGM3Color; */ + i = k+1; + j = strlen(newfmt); + + /* advance arg list once for small data, + twice for large */ + inarg++; +#ifdef _LDATA +#ifndef M_I386 + inarg++; +#endif +#endif + } /* if (wfDecChar) */ + + if (!wfRegChar && !wfDecChar) { /* neither */ + if (wfGM3Color && (lastcode!=cGMCodeNon)) { + newfmt[j]=cGMCodeNon; + lastcode=cGMCodeNon; + j++; + } + + newfmt[j]=fmt[i]; + i++; + j++; + if (fmt[i]!='\0') { + newfmt[j]=fmt[i]; + i++; + j++; + } + } /* neither */ + + } /* fmt[i]=='%' */ + } /* while */ + + newfmt[j]='\0'; + +/* print the output */ + i=sprintf(buffer, newfmt, + outval[0], outval[1], outval[2], outval[3], outval[4], + outval[5], outval[6], outval[7], outval[8], outval[9] + ,outval[10], outval[11], outval[12], outval[13], outval[14], + outval[15], outval[16], outval[17], outval[18], outval[19] + ); + _MacRet(i); +} + +/* finds number of 16-bit words on stack representing data element */ +static int _StackSize(cType, cPrec) +char cType; +char cPrec; +{ + int w,x; + + switch (cType) { + case 'c': { + w = sizeof(char); + break; + } + +#ifndef LATTICE + case 'i': +#endif + case 'd': case 'o': case 'u': case 'x': case 'X': { + if (cPrec=='l') + w = sizeof(long); + else + w = sizeof(int); + break; + } + + case 'f': case 'e': case 'g': case 'E': case 'G': { + if (cPrec=='l') + w = sizeof(double); + /* usual arithmetic conversion */ + else +#ifdef _MSC + if (cPrec=='L') + w = sizeof(long /*double*/); + else +#endif + w = sizeof(double); + break; + } + +#ifdef LATTICE + case 'P': +#else + case 'n': +#endif + case 's': case 'p': { +#ifndef LATTICE +#ifndef M_I386 + if (cPrec=='F') + w = sizeof(char far *); + else if (cPrec=='N') + w = sizeof(char near *); + else +#endif +#endif + w = sizeof(char *); + break; + } + } /* switch */ + + x = sizeof(int); + return((w+x-1)/x); /* rounds up to an integer */ +} diff --git a/gfm/dsqrt.c b/gfm/dsqrt.c new file mode 100755 index 000000000..3d313d80e --- /dev/null +++ b/gfm/dsqrt.c @@ -0,0 +1,53 @@ +/* DEC *SquareRootDecimal(pDst,pSrc1) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * + * DESCRIPTION + * Sets pDst = square root of pSrc1. + * + * SIDE EFFECTS + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_IMAG + * + * AUTHOR + * Jared Levy Aug 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *SquareRootDecimal(pDst,pSrc1) +DEC *pDst; +DEC *pSrc1; +{ + + _MacStart(GM_DSQRT); + _MacInVarD(pSrc1); + _MacOutVarD(pDst); + + if (_MacIsDecN(pSrc1)) { + _MacErr(GM_IMAG); + _MacRet(GM_NULL); + } + + /* no errors possible if pSrc1 >= 0 */ + _SqrtDec80Bit(pDst, pSrc1); + + /* reduce from 80-bit back to 64-bit */ + (void) _Sq5UnsTo4Uns(pDst); + + _MacRet(pDst); +} diff --git a/gfm/dsqx.c b/gfm/dsqx.c new file mode 100755 index 000000000..1ff6c23d0 --- /dev/null +++ b/gfm/dsqx.c @@ -0,0 +1,89 @@ +/* void _SqrtDec80Bit(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = square root of pSrc; + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. Always succeeds because CALLER GUARANTEES a valid 64-bit + * value for square root operation. + * + * AUTHOR + * Jared Levy Aug 7, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void _SqrtDec80Bit(pDst,pSrc) +DEC *pDst, *pSrc; +{ + int m, precision; + DEC *temp, dtemp, *nsrc, dnsrc; + + if(_MacIsDecZ(pSrc)) { + _MacDZero(pDst); + return; + } + + temp = &dtemp; + nsrc = &dnsrc; + +/* adjust pSrc to range .01 < nsrc < 1 */ + _MacDCopy(nsrc,pSrc); + m = MagnitudeOfDecimal(nsrc); + +/* calculate first guess */ + if ((m & 0X0001) == 0) { + m+=2; + nsrc->dc.id+= m; + if (nsrc->dc.id > GM_IMAXID) { + _DivUnsArrByPwrOf10(nsrc->dc.sl, 5, nsrc->dc.id-GM_IMAXID); + nsrc->dc.id = GM_IMAXID; + } + /* decTwoPoint59 = 2.59 */ + (void) _MulDec80Bit(temp, &decTwoPoint59, nsrc); + /* decPoint0819 = .0819 */ + (void) _AddDec80Bit(pDst, &decPoint0819, temp); } + else { + m++; + nsrc->dc.id+= m; + /* decPoint819 = .819 */ + (void) _MulDec80Bit(temp, &decPoint819, nsrc); + /* decPoint259 = .259 */ + (void) _AddDec80Bit(pDst, &decPoint259, temp); } + +/* do iterative calculation */ + precision = 3; + (void) _ScaleDec80Bit(pDst, pDst, 4); + while (precision < 18) { + precision = 2 * precision - 2; + (void) _DivRndDec80Bit(temp, nsrc, pDst, precision); + (void) _AddDec80Bit(pDst, pDst, temp); + _HalveUnsArr(pDst->dc.sl, 5); + } + +/* last iteration */ + (void) _DivDec80Bit(temp, nsrc, pDst); + (void) _AddDec80Bit(pDst, pDst, temp); + if (((pDst->dc.sl[0] & 1) == 0) || (pDst->dc.msd > 6553)) + _HalveUnsArr(pDst->dc.sl, 5); + else + (void) _MulDec80Bit(pDst, pDst, &decPoint5); + +/* recalibrate to correct magnitude */ + pDst->dc.id -= (m/2); + +} + diff --git a/gfm/dsscanf.c b/gfm/dsscanf.c new file mode 100755 index 000000000..89ba9bfd9 --- /dev/null +++ b/gfm/dsscanf.c @@ -0,0 +1,63 @@ +/* int StringScanDecimal(sBuffer, sFmt, arg,) + * + * ARGUMENT + * char *sFmt, *sBuffer; + * (?) arg; + * + * DESCRIPTION + * Scans arguments, which may include DEC structures, + * from a string, according + * to the format string sFmt. The function converts the DEC's to strings + * and calls scanf. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The number of fields scanned, the return from scanf. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_INVALIDID + * GM_CNVRW + * GM_CNVRE + * GM_NAN + * GM_EOF + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int StringScanDecimal(sBuffer, sFmt) +char *sBuffer; +char *sFmt; + +{ + int i; + char **pOutVal; + + _MacStart(GM_DSSCANF); + + pOutVal=&sFmt; + i=_ScanfAux(2, sBuffer, sFmt, + pOutVal[1], pOutVal[2], pOutVal[3], pOutVal[4], pOutVal[5], + pOutVal[6], pOutVal[7], pOutVal[8], pOutVal[9], pOutVal[10] +#ifndef _LDATA + ,pOutVal[11], pOutVal[12], pOutVal[13], pOutVal[14], pOutVal[15], + pOutVal[16], pOutVal[17], pOutVal[18], pOutVal[19], pOutVal[20] +#endif + ); + + _MacRet(i); +} + diff --git a/gfm/dsub.c b/gfm/dsub.c new file mode 100755 index 000000000..e3311db61 --- /dev/null +++ b/gfm/dsub.c @@ -0,0 +1,130 @@ +/* DEC *SubtractDecimal(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Subtracts the value in pSrc1 DEC to the value in pSrc2 DEC + * and puts the result in dest DEC structure. The sum is calculated + * to the maximum possible accuracy. The routine requires MINID, + * the minimum allowed implied decimal. + * + * SIDE EFFECTS + * On overflow, the dest value is indeterminate. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gmsystem.h" + +DEC *SubtractDecimal(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC t1, t2, *pts; + register int i,j; + int s1, s2; + + _MacStart(GM_DSUB); + + _MacInVar(pSrc1,GM_NULL); + _MacInVar(pSrc2,GM_NULL); + _MacOutVar(pDst,GM_NULL); + +/* if the source id's are different, make them equal with as much accuracy + as is possible, and protect source fields from change */ + +/* line up decimal places */ + i = pSrc1->dc.id-pSrc2->dc.id; + if (i) { + pts = &t1; + _MacDCopy(pts, pSrc1); + pts = &t2; + _MacDCopy(pts, pSrc2); + _MacDChgs(pts); + + if (i<0) { + pSrc1 = &t1; + pSrc2 = &t2; + i = -i; + } + else { + pSrc2 = &t1; + pSrc1 = &t2; + } + + j = _MulUnsArrByPwrOf10Limited( + pSrc1->dc.sl, i, 4); + pSrc1->dc.id += j; + if (jdc.sl, 4, i-j); + } + + s1 = pSrc1->dc.attr & 0x0001; + s2 = pSrc2->dc.attr & 0x0001; + if (i==0) + s2=1-s2; + + /* Subtract the numbers */ + pDst->dc.id = pSrc1->dc.id; + + if (s1 == s2) { +/* Add absolute values if signs are equal */ + _AddUnsArrToUnsArr(pSrc1->dc.sl, pSrc2->dc.sl, + pDst->dc.sl,5); + +/* if the first addition is an overflow, round down and try again */ + if (pDst->dc.sl[3] >= 32768L) { + if (pSrc1->dc.id <= GM_MINID) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + _DivUnsArrByUns(pDst->dc.sl, 10, 4); + pDst->dc.id--; + } + + /* sign of pDst same as sign of sources */ + pDst->dc.attr = s1; + } + + else { +/* subtract larger absolute value from smaller if signs are different */ + if (_CompareUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, 5) >= 0) { + /* pSrc1 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc1 */ + pDst->dc.attr = s1; + } + + else { + /* pSrc2 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc2->dc.sl, + pSrc1->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc2 */ + pDst->dc.attr = s2; + } + } + + _MacRet(pDst); +} diff --git a/gfm/dsux.c b/gfm/dsux.c new file mode 100755 index 000000000..7a0500556 --- /dev/null +++ b/gfm/dsux.c @@ -0,0 +1,119 @@ +/* int _SubDec80Bit(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * pSrc2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Subtracts the value in pSrc2 from the value in pSrc1 + * and puts the result in pDst DEC structure. The difference is calculated + * to the maximum possible accuracy. + * + * SIDE EFFECTS + * On overflow, the dest value is indeterminate. + * + * RETURNS + * Returns GM_SUCCESS unless an error, in which case the specific + * error code is returned. + * + * Note: uses an assembly language routine for the actual math + * + * AUTHOR + * Andy Anderson 13-JUL-87 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _SubDec80Bit(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC t1, t2, *pts; + register int i,j; + int s1, s2; + +/* if the source id's are different, make them equal with as much accuracy + as is possible, and protect source fields from change */ + +/* line up decimal places */ + i = pSrc1->dc.id-pSrc2->dc.id; + if (i) { + pts = &t1; + _MacDCopy(pts, pSrc1); + pts = &t2; + _MacDCopy(pts, pSrc2); + _MacDChgs(pts); + + if (i<0) { + pSrc1 = &t1; + pSrc2 = &t2; + i = -i; + } + else { + pSrc2 = &t1; + pSrc1 = &t2; + } + + j = _MulUnsArrByPwrOf10Limited( + pSrc1->dc.sl, i, 5); + pSrc1->dc.id += j; + if (jdc.sl, 5, i-j); + } + + s1 = pSrc1->dc.attr & 0x0001; + s2 = pSrc2->dc.attr & 0x0001; + if (i==0) + s2=1-s2; + + /* Subtract the numbers */ + pDst->dc.id = pSrc1->dc.id; + + if (s1 == s2) { +/* Add absolute values if signs are equal */ + _AddUnsArrToUnsArr(pSrc1->dc.sl, pSrc2->dc.sl, + pDst->dc.sl,5); + +/* if the first addition is an overflow, round down and try again */ + if (pDst->dc.sl[3] >= 32768L) { + if (pSrc1->dc.id <= GM_IMINID) + return(GM_OVERFLOW); + _DivUnsArrByUns(pDst->dc.sl, 10, 5); + pDst->dc.id--; + } + + /* sign of pDst same as sign of sources */ + pDst->dc.attr = s1; + } + + else { +/* subtract larger absolute value from smaller if signs are different */ + if (_CompareUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, 5) >= 0) { + /* pSrc1 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc1->dc.sl, + pSrc2->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc1 */ + pDst->dc.attr = s1; + } + + else { + /* pSrc2 has larger absolute value */ + (void) _SubUnsArrFromUnsArr(pSrc2->dc.sl, + pSrc1->dc.sl, + pDst->dc.sl,5); + /* sum has same sign as pSrc2 */ + pDst->dc.attr = s2; + } + } + + return(GM_SUCCESS); +} diff --git a/gfm/dswap.c b/gfm/dswap.c new file mode 100755 index 000000000..b48db8ce9 --- /dev/null +++ b/gfm/dswap.c @@ -0,0 +1,49 @@ +/* DEC *SwapDecimal(ptr1, ptr2) + * + * ARGUMENT + * ptr1 is a ptr to the source1 DEC structure. + * ptr2 is a ptr to the source2 DEC structure. + * + * DESCRIPTION + * Swaps the values of ptr1 and ptr2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to ptr1 if successful, otherwise + * returns GM_NULL. + * + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gmsystem.h" + +DEC *SwapDecimal(ptr1,ptr2) +DEC *ptr1; +DEC *ptr2; +{ + DEC temp[1]; + +/* source must be supplied !! */ + _MacStart(GM_DCPY); + _MacInVar(ptr2,GM_NULL); + _MacInVar(ptr1,GM_NULL); + + _MacDCopy(temp, ptr1); + _MacDCopy(ptr1, ptr2); + _MacDCopy(ptr2, temp); + + _MacRet(ptr1); +} diff --git a/gfm/dtan.c b/gfm/dtan.c new file mode 100755 index 000000000..327425efc --- /dev/null +++ b/gfm/dtan.c @@ -0,0 +1,94 @@ +/* DEC *TangentDecimal(pDst,pSrc) + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc; + * + * DESCRIPTION + * Sets pDst = the tangent of pSrc radians. + * + * SIDE EFFECTS + * Possible Errors: GM_NULLPOINTER, + * GM_OVERFLOW if | tan(pSrc) | > 2^63 + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Jared Levy Oct 16, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * ALGORITHM + * tan(x) = +/- (1 - cos(x) ^ 2 ) ^ .5 / cos(x) + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *TangentDecimal(pDst,pSrc) +DEC *pDst; +DEC *pSrc; + +{ + int i, isn=0; + DEC *nsrc, dnsrc, *size, dsize, *temp, dtemp; + DEC *cosx, dcosx, *sinx, dsinx; + + _MacStart(GM_DTAN); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + nsrc = &dnsrc; + _MacDCopy(nsrc, pSrc); + if (_MacIsDecN(nsrc)) { + isn = 1; + _MacDChgs(nsrc); + } + + temp = &dtemp; + if (CompareDecimal(nsrc, &decPiOver2) == 1) { + (void) _DivRndDec80Bit(size = &dsize, nsrc, &decPi, 0); + (void) _MulDec80Bit(temp, &decPi, size); + (void) _SubDec80Bit(nsrc, nsrc, temp); + if (_MacIsDecN(nsrc)) { + isn = 1 - isn; + _MacDChgs(nsrc); + } + } + + _CosDec80Bit(cosx = &dcosx, nsrc); + if (_MacIsDecZ(cosx)) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + (void) _MulDec80Bit(temp, cosx, cosx); + (void) _SubDec80Bit(temp, &decOne, temp); + _SqrtDec80Bit(sinx = &dsinx, temp); + i = _DivDec80Bit(pDst, sinx, cosx); + + if (i == GM_OVERFLOW) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + i = _Sq5UnsTo4Uns(pDst); + if (i != GM_SUCCESS) { + _MacErr(GM_OVERFLOW); + _MacRet(GM_NULL); + } + + if (isn) + _MacDChgs(pDst); + + _MacRet(pDst); +} diff --git a/gfm/dtoa.c b/gfm/dtoa.c new file mode 100755 index 000000000..0ee5b18fe --- /dev/null +++ b/gfm/dtoa.c @@ -0,0 +1,111 @@ +/* char *ConvDecimalToAscii( s, x) + * + * ARGUMENT + * DEC *x; + * char *s; + * + * + * DESCRIPTION + * Converts a DEC structure to an ascii string. A '-' will be printed + * for negative numbers, but a '+' sign will never be printed. A decimal + * point will be printed whenever the implied decimal is positive. Trailing + * zeroes after the decimal point will be printed. The number of decimal + * digits of the string is the same as the implied decimal of the DEC. + * + * Possible error: the string not being large enough + * + * SIDE EFFECTS + * THE DESTINATION char string MUST BE LONG ENOUGH FOR ALL THE DIGITS + * PLUS ANY SIGN, THE DECIMAL POINT AND THE TERMINATING NULL. + * + * RETURNS + * A string pointer if successful, NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NULLSTRING + * + * AUTHOR + * Jared Levy Feb 1, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gmsystem.h" + +char* ConvDecimalToAscii( s, x ) +DEC *x; +char *s; + +{ + int i, wDigits, wOut; + DEC a,*pa=&a; + char t[GM_IMAXID * 2]; + + _MacStart(GM_DTOA); + + if(!s) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (!x) { + strcpy(s, "(null)"); + _MacErr(GM_NULLPOINTER); + _MacRet (NULL); + } + + if (_MacBad(x)) { + strcpy(s, "(null)"); + _MacErr(GM_INIT); + _MacRet (NULL); + } + + + wDigits = wOut = 0; + _MacDCopy(pa,x); /* can't change source field */ + + if(_MacIsDecN(pa)) { + ++wOut; + } + +/* calculate wDigits */ + while(!(_MacIsDecZ(pa))) { + i = (int) _DivUnsArrByUns(pa->dc.sl,10,5); + t[wDigits] = (char) (i + 0x30); + wDigits++; + } + +/* precede by zeroes if necessary */ + for (; wDigits <= pa->dc.id; wDigits++) + t[wDigits] = '0'; + +/* add minus sign */ + if (wOut!=0) + s[0] = '-'; + + +/* copy wDigits into string */ + for (wDigits--; wDigits >= 0; wDigits--) { + if (wDigits == pa->dc.id - 1) { + s[wOut] = '.'; + wOut++; + } + s[wOut] = t[wDigits]; + wOut++; + } + +/* a # in the format string forces a decimal point */ + if (wfFlagNumber && x->dc.id==0) { + s[wOut] = '.'; + wOut++; + } + + s[wOut] = '\0'; + _MacRet (s); +} diff --git a/gfm/dtoac.c b/gfm/dtoac.c new file mode 100755 index 000000000..771add9e8 --- /dev/null +++ b/gfm/dtoac.c @@ -0,0 +1,118 @@ +/* char *ConvDecimalToAsciiComma( s, x) + * + * ARGUMENT + * DEC *x; + * char *s; + * + * + * DESCRIPTION + * Converts a DEC structure to an ascii string. A '-' will be printed + * for negative numbers, but a '+' sign will never be printed. A decimal + * point will be printed whenever the implied decimal is positive. Trailing + * zeroes after the decimal point will be printed. Commas will be included + * if the number's absolute value is >= 1000. The number of digits past + * the decimal point of the string will be the same as the implied decimal + * of the DEC. + * Possible error: the string not being large enough + * + * SIDE EFFECTS + * THE DESTINATION char string MUST BE LONG ENOUGH FOR ALL THE DIGITS + * PLUS ANY SIGN, THE DECIMAL POINT AND THE TERMINATING NULL. + * + * RETURNS + * A string pointer if successful, NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NULLSTRING + * + * AUTHOR + * Jared Levy Feb 1, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gmsystem.h" + +char* ConvDecimalToAsciiComma( s, x ) +DEC *x; +char *s; + +{ + int i, wDigits, wOut; + DEC a,*pa=&a; + char t[GM_IMAXID * 2]; + + _MacStart(GM_DTOAC); + + if(!s) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (!x) { + strcpy(s, "(null)"); + _MacErr(GM_NULLPOINTER); + _MacRet (NULL); + } + + if (_MacBad(x)) { + strcpy(s, "(null)"); + _MacErr(GM_INIT); + _MacRet (NULL); + } + + wDigits = wOut = 0; + _MacDCopy(pa,x); /* can't change source field */ + + if(_MacIsDecN(pa)) { + ++wOut; + } + +/* calculate wDigits */ + while(!(_MacIsDecZ(pa))) { + i = (int) _DivUnsArrByUns(pa->dc.sl,10,5); + t[wDigits] = (char) (i + 0x30); + wDigits++; + } + +/* precede by zeroes if necessary */ + for (; wDigits <= pa->dc.id; wDigits++) + t[wDigits] = '0'; + +/* add minus sign */ + if (wOut!=0) + s[0] = '-'; + + +/* copy wDigits into string */ + for (wDigits--; wDigits >= 0; wDigits--) { + if (wDigits == pa->dc.id - 1) { + s[wOut] = '.'; + wOut++; + } + + s[wOut] = t[wDigits]; + wOut++; + + if ((wDigits > pa->dc.id) && + ((wDigits - pa->dc.id) % 3 == 0)) { + s[wOut] = ','; + wOut++; + } + } + +/* a # in the format string forces a decimal point */ + if (wfFlagNumber && x->dc.id==0) { + s[wOut] = '.'; + wOut++; + } + + s[wOut] = '\0'; + _MacRet (s); +} diff --git a/gfm/dtoacr.c b/gfm/dtoacr.c new file mode 100755 index 000000000..143aaa612 --- /dev/null +++ b/gfm/dtoacr.c @@ -0,0 +1,152 @@ +/* char *ConvDecimalToAsciiCommaRound(s, x, n) + * + * ARGUMENT + * DEC *x; + * char *s; + * int n; + * + * + * DESCRIPTION + * Converts a DEC structure to an ascii string. A '-' will be printed + * for negative numbers, but a '+' sign will never be printed. A decimal + * point will be printed whenever the implied decimal is positive. Trailing + * zeroes after the decimal point will be printed. A comma will be printed + * every three digits left of the decimal point. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * A string pointer if successful, NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_CNVRW + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb 1, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gmsystem.h" + +char* ConvDecimalToAsciiCommaRound( s, x, n) +char *s; +DEC *x; +int n; /* 0...18 */ +{ + DEC a,*pa=&a; + int i, wDigits, wOut; + char t[GM_IMAXID * 2]; + + _MacStart(GM_DTOACR); + + if(!s) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (!x) { + strcpy(s, "(null)"); + _MacErr(GM_NULLPOINTER); + _MacRet (NULL); + } + + if (_MacBad(x)) { + strcpy(s, "(null)"); + _MacErr(GM_INIT); + _MacRet (NULL); + } + + if (nGM_MAXID) { + _MacErr(GM_INVALIDID); + n = GM_MAXID; + } + + wDigits = wOut = 0; + + /* preserve source integrity */ + _MacDCopy(pa,x); + if(_MacIsDecN(pa)) { + ++wOut; + } + + if (n < pa->dc.id) { + if (wfGMRound) + _DivUnsArrByPwrOf10(pa->dc.sl, 5, pa->dc.id - n); + else + _DivUnsArrByPwrOf10Trunc(pa->dc.sl, 5, pa->dc.id - n); + pa->dc.id = n; + if (_MacIsDecZ(pa)) + wOut = 0; + _MacErr(GM_CNVRW); + } + +/* calculate wDigits */ + while(!(_MacIsDecZ(pa))) { + i = (int) _DivUnsArrByUns(pa->dc.sl,10,5); + t[wDigits] = (char) (i + 0x30); + wDigits++; + } + +/* precede by zeroes if necessary */ + for (; wDigits <= pa->dc.id; wDigits++) + t[wDigits] = '0'; + +/* add minus sign */ + if(wOut!=0) { + s[0] = '-'; + } + +/* copy wDigits into string */ + for (wDigits--; wDigits >= 0; wDigits--) { + if (wDigits == pa->dc.id - 1) { + s[wOut] = '.'; + wOut++; + } + + s[wOut] = t[wDigits]; + wOut++; + + if ((wDigits > pa->dc.id) && + ((wDigits - pa->dc.id) % 3 == 0)) { + s[wOut] = ','; + wOut++; + } + } + + if (pa->dc.id < n) { + if (pa->dc.id == 0) { + s[wOut] = '.'; + wOut++; + } + for (i=pa->dc.id; i +#include +#include "gmsystem.h" + +void _ConvDecimalToAsciiFormatted( s, x, fmt ) +DEC *x; +char *s; +char *fmt; +{ + int wFStart, wOut=0, wWidth=0, wPrec=-1, wTotLen, i, t; + int wFlag=0, wJust=0; +/* + * Lattice C 6.0 moaned about my initialization of wfTemp, said it + * was redundant, so I took it out. + */ + mbool wfTemp /*=TRUE*/, wfZeroBlC=FALSE, wfZeroBlS=FALSE; + mbool wfAddLeft, wfAddRight, wfIsNeg=FALSE, wfIsZero; + mbool wfWidthStar=FALSE, wfFlagR=FALSE, wfFlagT=FALSE; + char cType, sNum[30], cAddLeft, sR[2], *sAddRight=sR; + DEC dCopy, *pCopy=&dCopy; + + sAddRight[0]='\0'; + wFStart=0; + +/* trace through format specification, storing parameters */ + + /* set flags */ + wfTemp=TRUE; + while (wfTemp) { + wFStart++; + cType = fmt[wFStart]; + if (cType=='-') + wJust = 3; + else if (cType==cGMFmtDlr) + wJust=(wJust > 2) ? wJust : 2; + else if (cType=='#') + wfFlagNumber=TRUE; + else if (cType==' ') + wFlag = (wFlag > 1) ? wFlag : 1; + else if (cType=='+') + wFlag = (wFlag > 2) ? wFlag : 2; + else if (cType==cGMFmtNegRgt2) + wFlag = (wFlag > 3) ? wFlag : 3; + else if (cType==cGMFmtNegRgt1) + wFlag = (wFlag > 4) ? wFlag : 4; + else if (cType==cGMFmtNegBrkt) + wFlag = (wFlag > 5) ? wFlag : 5; + else if (cType==cGMFmtNegPar) + wFlag = (wFlag > 6) ? wFlag : 6; + else if (cType==cGMFmtZeroBlC) + wfZeroBlC=TRUE; + else if (cType==cGMFmtZeroBlS) + wfZeroBlS=TRUE; + else wfTemp=FALSE; + } + + /* determine width */ + if (fmt[wFStart]=='0') { + wJust = (wJust > 1) ? wJust : 1; + wFStart++; + } + while (fmt[wFStart]>='0'&&fmt[wFStart]<='9') { + wWidth=wWidth*10+fmt[wFStart]-(int) '0'; + wFStart++; + } + + if (fmt[wFStart]=='*') { + wWidth = wGMStar; + wfWidthStar=TRUE; + wFStart++; + } + + /* determine precision */ + if (fmt[wFStart]=='.') { + wFStart++; + wPrec=0; + while (fmt[wFStart]>='0'&&fmt[wFStart]<='9') { + wPrec=wPrec*10+fmt[wFStart]-(int) '0'; + wFStart++; + } + if (fmt[wFStart]=='*') { + wPrec = wfWidthStar?wGMStar2:wGMStar; + wFStart++; + } + } + + /* ignore F, N, h, l, L */ + while (fmt[wFStart]=='F' || fmt[wFStart]=='N' || + fmt[wFStart]=='L' || fmt[wFStart]=='h' || + fmt[wFStart]=='l') + wFStart++; + +/* rounding & truncation flags */ + while (fmt[wFStart]==cGMFmtRnd || fmt[wFStart]==cGMFmtTrunc) { + if (fmt[wFStart]==cGMFmtRnd) + wfFlagR=TRUE; + if (fmt[wFStart]==cGMFmtTrunc) + wfFlagT=TRUE; + wFStart++; + } + + cType=fmt[wFStart]; + +/* bad character ==> print rest of format */ + wfTemp=FALSE; + while (!(cType==cGMFmt || cType==cGMFmtComma || cType==cGMFmtSci || + cType==cGMFmtSciE || cType==cGMFmtEng || cType==cGMFmtEngE)) { + s[wOut]=fmt[wFStart]; + wOut++; + wFStart++; + cType=fmt[wFStart]; + wfTemp=TRUE; + } + if (wfTemp) { + s[wOut]=fmt[wFStart]; + wOut++; + s[wOut]='\0'; + /* return global flags to default values */ + wfFlagNumber=FALSE; + return; + } + + if (!x || _MacBad(x)) { + if (wJust!=3) + for (i=6;i='1' && sNum[i]<='9') + wfIsZero=FALSE; + } + + if (wfZeroBlC && wfIsZero) { + for (i=0;idc.id : wPrec) + 1; + if (t==1&&!wfFlagNumber) + t--; + for (i=wTotLen;iwTotLen)) + s[wOut]=','; + else + s[wOut] = '0'; + wOut++; + } + } + +/* copy number */ + for (i=0;sNum[i]!='\0';i++) { + s[wOut]=sNum[i]; + wOut++; + } + +/* copy symbols on right */ + if (wfAddRight) + for (i=0;sAddRight[i]!='\0';i++) { + s[wOut]=sAddRight[i]; + wOut++; + } + +/* pad spaces on right */ + if (wJust==3) + for (i=wTotLen;i +#include +#include "gmsystem.h" + +char* ConvDecimalToAsciiRound( s, x, n) +char *s; +DEC *x; +int n; /* 0...18 */ +{ + DEC a,*pa=&a; + int i, wDigits, wOut; + char t[GM_IMAXID * 2]; + + _MacStart(GM_DTOAR); + /* check for null string (no number to convert) */ + if(!s) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (!x) { + strcpy(s, "(null)"); + _MacErr(GM_NULLPOINTER); + _MacRet (NULL); + } + + if (_MacBad(x)) { + strcpy(s, "(null)"); + _MacErr(GM_INIT); + _MacRet (NULL); + } + + if (nGM_MAXID) { + _MacErr(GM_INVALIDID); + n = GM_MAXID; + } + + wDigits = wOut = 0; + + /* preserve source integrity */ + _MacDCopy(pa,x); + if(_MacIsDecN(pa)) { + ++wOut; + } + + if (n < pa->dc.id) { +/* wfGMRound indicated rounding or truncating in conversion */ + if (wfGMRound) + _DivUnsArrByPwrOf10(pa->dc.sl, 5, pa->dc.id - n); + else + _DivUnsArrByPwrOf10Trunc(pa->dc.sl, 5, pa->dc.id - n); + pa->dc.id = n; + if (_MacIsDecZ(pa)) + wOut = 0; + _MacErr(GM_CNVRW); + } + +/* calculate wDigits */ + while(!(_MacIsDecZ(pa))) { + i = (int) _DivUnsArrByUns(pa->dc.sl,10,5); + t[wDigits] = (char) (i + 0x30); + wDigits++; + } + +/* precede by zeroes if necessary */ + for (; wDigits <= pa->dc.id; wDigits++) + t[wDigits] = '0'; + +/* add minus sign */ + if(wOut!=0) { + s[0] = '-'; + } + +/* copy wDigits into string */ + for (wDigits--; wDigits >= 0; wDigits--) { + if (wDigits == pa->dc.id - 1) { + s[wOut] = '.'; + wOut++; + } + + s[wOut] = t[wDigits]; + wOut++; + + } + + if (pa->dc.id < n) { + if (pa->dc.id == 0) { + s[wOut] = '.'; + wOut++; + } + for (i=pa->dc.id; i +#include "gmsystem.h" + +long ConvDecimalToDollarsAndCents(pc, x ) +DEC *x; +int *pc; +{ + long d; + DEC dxc, *xc=&dxc; + + _MacStart(GM_DTODC); + _MacInVar(x, 0L); + if (!pc) { + _MacErr(GM_NULLPOINTER); + _MacRet(0); + } + + _ScaleDec80Bit(xc, x, 2); + + if (!xc->ls.lsl[1] && !(xc->ls.lsl[0] & 0x80000000L)) { + d = xc->ls.lsl[0]/100L; + *pc = (int) (xc->ls.lsl[0] - d * 100L); + } + else { + *pc = _DivUnsArrByUns(xc->dc.sl, 100, 5); + if (xc->ls.lsl[1] || (xc->ls.lsl[0] & 0x80000000L)) { + _MacErr(GM_OVERFLOW); + _MacRet(0L); + } + d = xc->ls.lsl[0]; + } + + if (_MacIsDecN(xc)) + d = -d; + + _MacRet(d); +} diff --git a/gfm/dtodf.c b/gfm/dtodf.c new file mode 100755 index 000000000..9b6b45d6f --- /dev/null +++ b/gfm/dtodf.c @@ -0,0 +1,75 @@ +/* double ConvDecimalToDouble(x) + * + * ARGUMENT + * DEC *x; + * + * DESCRIPTION + * Converts a DEC to a double. It requires a global variable eTwoTo32, + * 2^32 in double notation, and ergGMPowersOfTenDouble, an array of + * powers of ten in double notation. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The double if the conversion is successful, and the error code + * otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +double ConvDecimalToDouble(x) +DEC *x; +{ + + int p; + double f, g; + + _MacStart(GM_DTODF); + /* check for null pointer */ + _MacInVar(x, 0.0); + +/* change 64-bit number to double */ + f = (double) x->ls.lsl[0]; + if (f<0.0) + f+= eTwoTo32; + + if (x->ls.lsl[1] != 0) { + g = (double) x->ls.lsl[1]; + if (g<0.0) + g+=eTwoTo32; + f+= (g * eTwoTo32); + } + + if (x->ls.lmsd != 0) + f+= ((double) x->ls.lmsd) * eTwoTo64; + +/* adjust by power of 10 */ + p = x->ls.lid; + while (p>=25) { + f = f / 1e25; + p-= 25; + } + f = f / ergGMPowersOfTenDouble[p]; + +/* make negative numbers negative */ + if (_MacIsDecN(x)) { + f = -f; + } + + _MacRet(f); +} + diff --git a/gfm/dtoeng.c b/gfm/dtoeng.c new file mode 100755 index 000000000..b1242c579 --- /dev/null +++ b/gfm/dtoeng.c @@ -0,0 +1,197 @@ +/* char *ConvDecimalToEngineering( s, x, p) + * + * ARGUMENT + * DEC *x; + * char *s; + * int p; + * + * DESCRIPTION + * Converts a DEC structure to an ascii string. A '-' will be printed + * for negative numbers, but a '+' sign will never be printed. A decimal + * point will be printed whenever the implied decimal is positive. Trailing + * zeroes after the decimal point will be printed. The number of decimal + * digits of the string is the same as the implied decimal of the DEC. + * The number is printed in engineering notation, similar to the %e type + * of printf, with a precision of p (i.e. p+1 digits). A negative p implies + * the default precision of the DEC. + * The exponent is always a mutiple of 3, and the mantissa is between + * 1 and 1000. + * Possible error: the string not being large enough + * + * SIDE EFFECTS + * THE DESTINATION char string MUST BE LONG ENOUGH FOR ALL THE DIGITS + * PLUS ANY SIGN, THE DECIMAL POINT AND THE TERMINATING NULL. + * + * RETURNS + * A string pointer if successful, NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_CNVRW + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb 1, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gmsystem.h" + +char *ConvDecimalToEngineering( s, x, p) +DEC *x; /* DEC stucture */ +char *s; /* string */ +int p; /* precision */ +{ + int i, wDigits, wOut, wExp, diff, ip, rup, emod3; + DEC a,*pa=&a; + char t[GM_IMAXID * 2]; + + _MacStart(GM_DTOENG); + + if(!s) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (!x) { + strcpy(s, "(null)"); + _MacErr(GM_NULLPOINTER); + _MacRet (NULL); + } + + if (_MacBad(x)) { + strcpy(s, "(null)"); + _MacErr(GM_INIT); + _MacRet (NULL); + } + + if (p>18) { + _MacErr(GM_INVALIDID); + p=18; + } + p++; + + wDigits = wOut = 0; + _MacDCopy(pa,x); /* can't change source field */ + + if(_MacIsDecN(pa)) { + ++wOut; + } + +/* calculate digits */ + while(!(_MacIsDecZ(pa))) { + i = (int) _DivUnsArrByUns(pa->dc.sl,10,5); + t[wDigits] = (char) (i + 0x30); + wDigits++; + } + +/* calculate exponent */ + wExp = wDigits - pa->dc.id - 1; + + if (wDigits == 0) { /* case pa == 0 */ + t[0]='0'; + wDigits++; + wExp=0; + } + +/* p<=0 --> use default precision */ + if (p<=0) + p=wDigits; + +/* too many digits */ + if (wDigits>p) { + diff = wDigits-p; + rup = ((t[diff-1] >='5') ? 1 : 0); + for (i=0; i=0; i--) + t[i+diff]=t[i]; + for (i=0; i= 0; ip--) { + if (p - ip == emod3 + 2) { + s[wOut] = '.'; + wOut++; + } + s[wOut] = t[ip]; + wOut++; + } + + if (emod3 >= p) { + s[wOut] = '0'; + wOut++; + if (emod3 > p) { + s[wOut] = '0'; + wOut++; + } + } + +/* a # in the format string forces a decimal point */ + if (wfFlagNumber && p<=1) { + s[wOut] = '.'; + wOut++; + } + +/* add exponent */ + s[wOut] = cGMSymExp; /* 'e' or 'E' */ + wOut++; + + if (wExp>=0) + s[wOut]='+'; + else { + s[wOut]='-'; + wExp = -wExp; + } + wOut++; + + s[wOut]='0'; + wOut++; + s[wOut]= (char) (0x30 + wExp/10); + wOut++; + s[wOut]= (char) (0x30 + wExp%10); + wOut++; + + s[wOut] = '\0'; + _MacRet (s); + +} diff --git a/gfm/dtofr.c b/gfm/dtofr.c new file mode 100755 index 000000000..2b35d2362 --- /dev/null +++ b/gfm/dtofr.c @@ -0,0 +1,83 @@ +/* DEC long ConvDecimalToFraction( pn, x, d); + * + * ARGUMENT + * DEC *x; input DEC + * long i; integer part + * int *pn; numerator + * int d; denominator + * + * DESCRIPTION + * Rounds the DEC x to a mixed fraction with denominator d. + * The integer part is stored returned, while the numberator, + * between 0 and d-1, is stored in *pn. + * + * SIDE EFFECTS + * x is indeterminate on error. + * + * RETURNS + * The integer part if the conversion is successful, and 0L otherwise. + * + * POSSIBLE ERROR CODES + * GM_NULLPOINTER + * GM_DIV0 + * GM_OVERFLOW + * + * AUTHOR + * Jared Levy Oct. 10, 1989 + * Copyright (C) 1989-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gmsystem.h" + +long ConvDecimalToFraction( pn, x, d) +int *pn; +DEC *x; +int d; +{ + long i; + DECP x0, xf, d0; + + _MacStart(GM_DTOFR); + _MacInVar(x, 0L); + if (!pn) { + _MacErr(GM_NULLPOINTER); + _MacRet(0L); + } + + /* check for 0 denominator */ + if (!d) { + _MacErr(GM_DIV0); + _MacRet(0L); + } + + /* find integer part */ + _TruncateDec80Bit(x0, x, 0); + i = x0->ls.lsl[0]; + if (x0->ls.lsl[1] || (i & 0x80000000L)) { + _MacErr(GM_OVERFLOW); + _MacRet(0L); + } + + /* numerator = (x - integer part) * denom. */ + _SubDec80Bit(xf, x, x0); + ConvLongToDecimal(d0, (long) d); + _MulDec80Bit(xf, xf, d0); + _ScaleDec80Bit(xf, xf, 0); + *pn = xf->dc.sl[0]; + + /* if numer. = den., then increase i by 1 and set num = 0 */ + if (*pn == d) { + *pn=0; + i++; + } + + /* make int. part negative if number is negative */ + if (_MacIsDecN(x)) + i = -i; + + _MacRet(i); +} diff --git a/gfm/dtoi.c b/gfm/dtoi.c new file mode 100755 index 000000000..7b416d4ae --- /dev/null +++ b/gfm/dtoi.c @@ -0,0 +1,89 @@ +/* int ConvDecimalToInt(x) + * + * ARGUMENT + * DEC *x; + * + * DESCRIPTION + * Converts a DEC to an integer. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The integer if the conversion is successful, and the error code + * otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_CNVRE + * GM_CNVRW + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int ConvDecimalToInt(x) +DEC *x; +{ + DEC temp; + DEC *pt, dn, *n=&dn; + int i; + mbool wfIsNeg; + short s; + + _MacStart(GM_DTOI); + /* check for null pointer */ + _MacInVar(x, 0); + + _MacDCopy(n, x); + +/* + * The following three lines of code shouldn't be separated. I ran into + * a problem with Zortech v2.06. If the _ScaleDec80Bit is called right + * after executing _MacIsDecN, the 0 in the parameter list sometimes + * gets changed to a -1. This is bad. Expect Zortech to fix it someday, + * but since I only had to change the order of execution of these three + * lines, no need to change. Same problem is found in DTOL.C. + */ + + wfIsNeg = _MacIsDecN(n); + pt = &temp; + (void) _ScaleDec80Bit(pt, n, 0); /* convert to integer */ + + +/* |x| <= 32767 */ + if ((pt->dc.sl[1] == 0) && (pt->dc.sl[0]< 32768L) + && (pt->dc.sl[2] == 0) + && (pt->dc.sl[3] == 0) && (pt->dc.msd == 0)) { + i = (int) (pt->dc.sl[0]); + if (CompareDecimal(pt, n)!=0) + _MacErr(GM_CNVRW); + if(wfIsNeg) + {_MacRet(-i);} + else + _MacRet (i); + } + +/* check for -32768 */ + if ((pt->dc.sl[0] == 32768L) && (wfIsNeg) + && (pt->dc.sl[1] == 0) && (pt->dc.sl[2] == 0) + && (pt->dc.sl[3] == 0) && (pt->dc.msd == 0)) { + if (CompareDecimal(pt, n)!=0) + _MacErr(GM_CNVRW); + s = (short) -32768L; + _MacRet((int) s); + } +/* overflow */ + _MacErr(GM_CNVRE); + _MacRet(0); +} + diff --git a/gfm/dtol.c b/gfm/dtol.c new file mode 100755 index 000000000..00325655a --- /dev/null +++ b/gfm/dtol.c @@ -0,0 +1,83 @@ +/* long ConvDecimalToLong(x) + * + * ARGUMENT + * DEC *x; + * + * DESCRIPTION + * Converts a DEC to a long. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The integer if the conversion is successful, and the error code + * otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_CNVRE + * GM_CNVRW + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +long ConvDecimalToLong(x) +DEC *x; +{ + DEC temp; + DEC *pt=&temp, dn, *n=&dn; + mbool wfIsNeg; + long l; + unsigned long maxpos=2147483647L; + + _MacStart(GM_DTOL); + _MacInVar(x, 0L); + + _MacDCopy(n, x); + +/* + * The following two lines of code shouldn't be separated. I ran into + * a problem with Zortech v2.06. If the _ScaleDec80Bit is called right + * after executing _MacIsDecN, the 0 in the parameter list sometimes + * gets changed to a -1. This is bad. Expect Zortech to fix it someday, + * but since I only had to change the order of execution of these three + * lines, no need to change. Same problem is found in DTOL.C. + */ + (void) _ScaleDec80Bit(pt, n, 0); /* convert to integer format */ + wfIsNeg = _MacIsDecN(n); + +/* |x| < 2147483648 */ + if ((pt->ls.lsl[1] == 0) && !(pt->ls.lsl[0] & 0x80000000/*UL*/) + && (pt->dc.msd == 0)) { + l = (long) (pt->ls.lsl[0]); + if (CompareDecimal(n,pt)!=0) + _MacErr(GM_CNVRW); + if (wfIsNeg) + {_MacRet(-l)} + else + _MacRet(l); + } + +/* check for -2147483648 AND "logical" _MacRet to get by MSC bug*/ + if (wfIsNeg && (pt->ls.lsl[0] == 0x80000000L) && + (pt->ls.lsl[1] == 0) && (pt->ls.lmsd == 0)) { + if (CompareDecimal(n,pt)!=0) + _MacErr(GM_CNVRW); + _MacRet((long) ~maxpos); + } + +/* overflow */ + _MacErr(GM_CNVRE); + _MacRet(0L); +} + diff --git a/gfm/dtosci.c b/gfm/dtosci.c new file mode 100755 index 000000000..501ca9c24 --- /dev/null +++ b/gfm/dtosci.c @@ -0,0 +1,186 @@ +/* char *ConvDecimalToScientific( s, x, p) + * + * ARGUMENT + * DEC *x; + * char *s; + * int p; + * + * DESCRIPTION + * Converts a DEC structure to an ascii string. A '-' will be printed + * for negative numbers, but a '+' sign will never be printed. A decimal + * point will be printed whenever the implied decimal is positive. Trailing + * zeroes after the decimal point will be printed. The number of decimal + * digits of the string is the same as the implied decimal of the DEC. + * The number is printed in scientific notation, similar to the %e type + * of printf, with a precision of p (i.e. p+1 digits). A negative p implies + * the default precision of the DEC. + * Possible error: the string not being large enough + * + * SIDE EFFECTS + * THE DESTINATION char string MUST BE LONG ENOUGH FOR ALL THE DIGITS + * PLUS ANY SIGN, THE DECIMAL POINT AND THE TERMINATING NULL. + * + * RETURNS + * A string pointer if successful, NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NULLSTRING + * GM_CNVRW + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb 1, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gmsystem.h" + +char *ConvDecimalToScientific( s, x, p) +DEC *x; /* DEC stucture */ +char *s; /* string */ +int p; /* precision */ +{ + int i, wDigits, wOut, wExp, diff, ip, rup; + DEC a,*pa=&a; + char t[GM_IMAXID * 2]; + + _MacStart(GM_DTOSCI); + + if(!s) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (!x) { + strcpy(s, "(null)"); + _MacErr(GM_NULLPOINTER); + _MacRet (NULL); + } + + if (_MacBad(x)) { + strcpy(s, "(null)"); + _MacErr(GM_INIT); + _MacRet (NULL); + } + + if (p>18) { + _MacErr(GM_INVALIDID); + p=18; + } + p++; + + wDigits = wOut = 0; + _MacDCopy(pa,x); /* can't change source field */ + + if(_MacIsDecN(pa)) { + ++wOut; + } + +/* calculate digits */ + while(!(_MacIsDecZ(pa))) { + i = (int) _DivUnsArrByUns(pa->dc.sl,10,5); + t[wDigits] = (char) (i + 0x30); + wDigits++; + } + +/* calculate exponent */ + wExp = wDigits - pa->dc.id - 1; + + if (wDigits == 0) { /* case pa == 0 */ + t[0]='0'; + wDigits++; + wExp=0; + } + +/* p<=0 --> use default precision */ + if (p<=0) + p=wDigits; + +/* too many digits */ + if (wDigits>p) { + diff = wDigits-p; + rup = ((t[diff-1] >='5') ? 1 : 0); + for (i=0; i=0; i--) + t[i+diff]=t[i]; + for (i=0; i1) { + s[wOut] = '.'; + wOut++; + for (ip--; ip >= 0; ip--) { + s[wOut] = t[ip]; + wOut++; + } + } + +/* a # in the format string forces a decimal point */ + if (wfFlagNumber && p<=1) { + s[wOut] = '.'; + wOut++; + } + +/* add exponent */ + s[wOut] = cGMSymExp; /* 'e' or 'E' */ + wOut++; + + if (wExp>=0) + s[wOut]='+'; + else { + s[wOut]='-'; + wExp = -wExp; + } + wOut++; + + s[wOut]='0'; + wOut++; + s[wOut]= (char) (0x30 + wExp/10); + wOut++; + s[wOut]= (char) (0x30 + wExp%10); + wOut++; + + s[wOut] = '\0'; + _MacRet (s); + +} diff --git a/gfm/dtoui.c b/gfm/dtoui.c new file mode 100755 index 000000000..2da4661d1 --- /dev/null +++ b/gfm/dtoui.c @@ -0,0 +1,59 @@ +/* unsigned ConvDecimalToUns(x) + * + * ARGUMENT + * DEC *x; + * + * DESCRIPTION + * Converts a DEC to an unsigned (integer). + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The integer if the conversion is successful, and the error code + * otherwise. + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_CNVRE + * GM_CNVRW + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +unsigned ConvDecimalToUns(x) +DEC *x; +{ + DEC temp; + DEC *pt; + unsigned SHORT i; + + _MacStart(GM_DTOUI); + _MacInVar(x, 0); + + pt = &temp; + (void) _ScaleDec80Bit(pt, x, 0); /* convert to integer */ + +/* 0 <= x <= 65535 */ + if(!(pt->dc.sl[1] | pt->dc.sl[2] | pt->dc.sl[3] | pt->dc.msd) + && !_MacIsDecN(pt)) { + if (CompareDecimal(x,pt)!=0) + _MacErr(GM_CNVRW); + i = pt->dc.sl[0]; + _MacRet (i); + } + +/* overflow */ + _MacErr(GM_CNVRE); + _MacRet(0); +} diff --git a/gfm/dtoul.c b/gfm/dtoul.c new file mode 100755 index 000000000..c487e1922 --- /dev/null +++ b/gfm/dtoul.c @@ -0,0 +1,58 @@ +/* unsigned long dtoul(x) + * + * ARGUMENT + * DEC *x; + * + * DESCRIPTION + * Converts a DEC to an unsigned long. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The long if the conversion is successful, and the error code + * otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_CNVRE + * GM_CNVRW + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +unsigned long ConvDecimalToUnsLong(x) +DEC *x; +{ + DEC t; + DEC *pt; + unsigned long i; + + _MacStart(GM_DTOUL); + _MacInVar(x, 0L); + + pt=&t; + (void) _ScaleDec80Bit(pt, x, 0); + +/* 0 <= x < 2^32 */ + if (!_MacIsDecN(pt) && (pt->ls.lsl[1] == 0) && (pt->dc.msd == 0)) { + if (CompareDecimal(pt,x)!=0) + _MacErr(GM_CNVRW); + i = pt->ls.lsl[0]; + _MacRet (i); + } + +/* overflow */ + _MacErr(GM_CNVRE); + _MacRet((unsigned) 0L); +} diff --git a/gfm/dtrunc.c b/gfm/dtrunc.c new file mode 100755 index 000000000..69b4e7d2b --- /dev/null +++ b/gfm/dtrunc.c @@ -0,0 +1,79 @@ +/* DEC *TruncateDecimal(pDst,pSrc1,wID) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * wID is the integer specifying location of implied decimal + * for the conversion. + * + * DESCRIPTION + * Adjusts the number in pSrc1 (if necessary) while copying it to + * pDst adjusting pDst to wID number of decimal places. If pDst is null + * on entry, tries to first create a pDst, then the conversion. When the + * number of decimal places decreases, the result is truncated (rounded + * towards zero). + * + * SIDE EFFECTS + * pSrc1 remains unchanged and pDst is undefined on error. + * + * RETURNS + * Returns a pointer to the pDst structure unless error, + * in which case it returns a NULL(a C false). On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_INVALIDID + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy 5/28/87 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * +*/ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *TruncateDecimal(pDst,pSrc1,wID) +DEC *pDst, *pSrc1; +int wID; +{ + int i; + + _MacStart(GM_DTRUNC); + _MacInVarD(pSrc1); + _MacOutVarD(pDst); + + if (wIDGM_MAXID) { + _MacErr(GM_INVALIDID); + _MacRet(GM_NULL); + } + + if(_MacIsDecZ(pSrc1)) { + _MacDZero(pDst); + pDst->dc.id = wID; + _MacRet(pDst); + } + + i = _TruncateDec80Bit(pDst, pSrc1, wID); + +/* check if number can fit into 64 bits (no shifting allowed) */ + if (!((pDst->dc.msd == 0) && (pDst->dc.sl[3] < 32768L))) + i = GM_OVERFLOW; + + if (i != GM_SUCCESS) { + _MacErr(i); + _MacRet(GM_NULL); + } + + if (_MacIsDecZ(pDst)) + _MacErr(GM_UNDERFLOW); + + _MacRet(pDst); +} diff --git a/gfm/dtrux.c b/gfm/dtrux.c new file mode 100755 index 000000000..74d912a2c --- /dev/null +++ b/gfm/dtrux.c @@ -0,0 +1,61 @@ +/* int _TruncateDec80Bit(pDst,pSrc1,wID) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * wID is the integer specifying location of implied decimal + * for the conversion. + * + * DESCRIPTION + * Adjusts the number in pSrc1 (if necessary) while copying it to + * pDst adjusting pDst to wID number of decimal places. If pDst is null + * on entry, tries to first create a pDst, then the conversion. + * + * SIDE EFFECTS + * pSrc1 remains unchanged, pDst is undefined on error. + * + * RETURNS + * Returns GM_SUCCESS unless there is an error, + * in which case it returns the error code. + * + * + * AUTHOR + * Andy Anderson 27-JAN-1987 19:25 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _TruncateDec80Bit(pDst,pSrc1,wID) +DEC *pDst, *pSrc1; +int wID; +{ + int i; + + _MacDCopy(pDst,pSrc1); + + i = pSrc1->ls.lid - wID; + + /* Make sure there's an adjustment to do */ + if(i == 0) { + return(GM_SUCCESS); + } + + /* set implied decimal */ + pDst->ls.lid = wID; + if(i>0) { + _DivUnsArrByPwrOf10Trunc(pDst->dc.sl,5,i); + } + else { + if((_MulUnsArrByPwrOf10(pDst->dc.sl, -i, 5) + != GM_SUCCESS) || (pDst->dc.msd & 0x8000)) + return(GM_OVERFLOW); + } + + return(GM_SUCCESS); +} diff --git a/gfm/dzero.c b/gfm/dzero.c new file mode 100755 index 000000000..98da1934d --- /dev/null +++ b/gfm/dzero.c @@ -0,0 +1,43 @@ +/* DEC *ZeroDecimal(pSrc1) + * + * ARGUMENT + * pSrc1 is a ptr to the source1 DEC structure. + * + * DESCRIPTION + * Zeroes the structure pSrc1. + * + * SIDE EFFECTS + * If a NULL ptr is passed, creates zeroed NULL DEC for caller. + * + * RETURNS + * Returns a ptr to the zeroed structure if successful. + * Otherwise returns a GM_NULL. + * + * POSSIBLE ERROR CODES + * GM_NULLPOINTER + * + * AUTHOR + * Andy Anderson 13-JAN-1987 16:20 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ZeroDecimal(x) +DEC *x; +{ + + _MacStart(GM_DZERO); + + _MacOutVarD(x); + + /* Then zero the structure */ + _MacDZero(x); + + _MacRet(x); +} diff --git a/gfm/dzeroarr.c b/gfm/dzeroarr.c new file mode 100755 index 000000000..5d8581553 --- /dev/null +++ b/gfm/dzeroarr.c @@ -0,0 +1,62 @@ +/* DEC **ZeroDecimalArray(dst, n); + * + * ARGUMENT + * DEC **dst; + * int n; + * + * DESCRIPTION + * Sets each element in an array of n DEC pointers to 0 with id 2. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns dst if successful, + * otherwise returns GM_NULLARR. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC **ZeroDecimalArray(dst, n) +DEC **dst; +int n; +{ + int i; + + _MacStart(GM_DZEROARR); + + if (n<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + + if(!dst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + +/* check that each element of array is allocated */ + for (i=0; i +#include "gmsystem.h" + +DEC *ConvEffectiveToNominal(nom, eff, nper) +DEC *eff,*nom; +int nper; +{ + DEC dtemp, *temp=&dtemp, ddper, *dper=&ddper; + + _MacStart(GM_EFFTONOM); + + _MacInVarD(eff); + _MacOutVarD(nom); + +/* nper must be >= 1 if not continuous compounding */ + if (((nper<=0)&&(nper!=GM_CONTINUOUS)) + ||CompareDecimal(eff,&decMinusHundred)<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + +/* convert percent to decimal */ + _MacDCopy(temp, eff); + temp->dc.id+=2; + + if (nper==GM_CONTINUOUS) { /* continuous compounding */ + (void) _AddDec80Bit(temp, temp, &decOne); + (void) _LnDec80Bit(temp, temp); + } + else { /* finite compounding */ + (void) ConvLongToDecimal(dper, (long) nper); + (void) _AddDec80Bit(temp, temp, &decOne); + (void) _LnDec80Bit(temp, temp); + (void) _DivDec80Bit(temp, temp, dper); + (void) _ExpDec80Bit(temp, temp); + (void) _SubDec80Bit(temp, temp, &decOne); + (void) _MulDec80Bit(temp, temp, dper); + } + +/* convert decimal to percent */ + if (temp->dc.id>=2) + temp->dc.id-=2; + else { + (void) ConvLongToDecimal(dper, 100L); + (void) _MulDec80Bit(temp, temp, dper); + } + + if (_Sq5UnsTo4Uns(temp)!=GM_SUCCESS) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + _MacDCopy(nom,temp); + _MacRet(nom); +} diff --git a/gfm/errname.c b/gfm/errname.c new file mode 100755 index 000000000..4a64add2a --- /dev/null +++ b/gfm/errname.c @@ -0,0 +1,67 @@ +/* char *ErrorName(dst, num); + * + * ARGUMENT + * char *pDst; + * int num; + * + * DESCRIPTION + * This function copies the string name corresponding to a given + * error number into dst. dst must be character array allocated to have + * at least 15 characters. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * dst if successful, otherwise NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLSTRING + * GM_ARGVAL + * + * AUTHOR + * Don Killen 11-Jan-1988 19:29:08 + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ +#include +#include +#include "gmsystem.h" + +char *ErrorName(dst, num) +char *dst; +int num; +{ + static char *codes[]={ "GM_SUCCESS","GM_NULLPOINTER", + "GM_NULLSTRING","GM_INIT", + "GM_OVERFLOW","GM_UNDERFLOW", + "GM_NAN","GM_CNVRE","GM_CNVRW","GM_DIV0","GM_PWR0","GM_IMAG", + "GM_NOMEMORY","GM_INVALIDID","GM_NOTFOUND","GM_ARGVAL", + "GM_EOF",""}; + int err; + + _MacStart(GM_ERRNAME); + + if (!dst) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (num == GM_SUCCESS) { + strcpy(dst, "GM_SUCCESS"); + _MacRet(dst); + } + + err = GM_BASE - num; + if (err<0 || err>16) { + _MacErr(GM_ARGVAL); + _MacRet(NULL); + } + + strcpy(dst, codes[err]); + _MacRet(dst); +} diff --git a/gfm/frtod.c b/gfm/frtod.c new file mode 100755 index 000000000..4aa938dd4 --- /dev/null +++ b/gfm/frtod.c @@ -0,0 +1,67 @@ +/* DEC *ConvFractionToDecimal( x, i, n, d) + * + * ARGUMENT + * DEC *x; output + * long i; integer part + * int n; numerator + * int d; denominator + * + * DESCRIPTION + * Sets x equal to the fraction i + n/d. + * + * SIDE EFFECTS + * x is indeterminate on error. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * GM_NULLPOINTER + * GM_DIV0 + * + * AUTHOR + * Jared Levy Oct. 10, 1989 + * Copyright (C) 1989-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gmsystem.h" + +DEC *ConvFractionToDecimal( x, i, n, d) +DEC *x; +long i; +int n; +int d; +{ + int isneg=0; + + _MacStart(GM_FRTOD); + _MacOutVarD(x); + + /* check for 0 denominator */ + if (!d) { + _MacErr(GM_DIV0); + _MacRet(GM_NULL); + } + + /* handle negative numbers */ + if (i<0) { + isneg = 1; + i = -i; + n = (n<0) ? -n : n; + d = (d<0) ? -d : d; + } + + ConvLongToDecimal(x, (long) n); + DivideDecimalByLong(x, x, (long) d); + AddLongToDecimal(x, x, i); + + DeleteTrailingZeroes(x, x); + + x->dc.attr = isneg; + + _MacRet(x); +} diff --git a/gfm/funname.c b/gfm/funname.c new file mode 100755 index 000000000..d8d985a19 --- /dev/null +++ b/gfm/funname.c @@ -0,0 +1,62 @@ +/* char *FunctionName(dst, num); + * + * ARGUMENT + * char *pDst; + * int num; + * + * DESCRIPTION + * This function copies the string name corresponding to a given + * function number into dst. dst must be character array allocated to have + * at least 32 characters. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * dst if successful, otherwise NULL. + * + * POSSIBLE Function CODES + * + * GM_NULLSTRING + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ +#include +#include +#include "gmsystem.h" +#include "gmfname.h" + +char *FunctionName(dst, num) +char *dst; +int num; +{ + int err; + + _MacStart(GM_FUNNAME); + + if (!dst) { + _MacErr(GM_NULLSTRING); + _MacRet(NULL); + } + + if (num==0) { + _MacDCopy(dst, "None"); + _MacRet(dst); + } + + err = num - GM_FN_BASE; + if (err<0 || err>GM_FN_NUM) { + _MacErr(GM_ARGVAL); + _MacRet(NULL); + } + + strcpy(dst, fnames[err]); + _MacRet(dst); +} diff --git a/gfm/gcmp.asm b/gfm/gcmp.asm new file mode 100755 index 000000000..9294d9209 --- /dev/null +++ b/gfm/gcmp.asm @@ -0,0 +1,106 @@ + ; int _CompareUnsArr(src1,src2,n) + ; + ; ARGUMENT + ; src1, src2 point to unsigned arrays of length 'n' + ; + ; DESCRIPTION + ; + ; Compares src1 to scr2. Src1 and Src2 remain unchanged. + ; + ; SIDE EFFECTS + ; None. + ; + ; RETURNS + ; Returns zero if src1=src2, 1 if src1>src2, -1 if src2>src1. + ; + ; AUTHOR + ; Andy Anderson 14-JAN-1987 14:45 + ; Copyright (C) 1987-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; + ; + ; + include model.h + include prologue.h + include gm.equ + + + pseg gmath +; +; if large memory model then: +; +; parm1_ = ptr to source 1 +; parm3_ = ptr to source 2; +; parm5_ = number of unsigned's to compare +; +; for if small model then +; parm1_ = ptr to source1 +; parm2_ = ptr to source2 +; parm3_ = number of unsigned's to compare +; + cproc _CompareUnsArr,,_gcmp +if _LDATA + push ds + push es + lds si,parm1_ ; ptr to a + les di,parm3_ ; ptr to b + mov cx,parm5_ ; number of ints to compare +else + mov si,parm1_ + mov di,parm2_ + mov cx,parm3_ +endif +; +; then do the compare, starting at the most significant bits +; which are considered signed, others are unsigned +; + mov bx,cx ; make number of unsigned's an + sal bx,1 ; offset into array + sub bx,2 ; now yy+bx pts to last int + mov ax,[bx+si] ; src1 msb +if _LDATA + cmp ax,Word Ptr es:[bx+di] +else + cmp ax,Word Ptr [bx+di] +endif + ja g1 ; src1>src2 unsigned! + jb l1 ; src1src2 unsigned + jb l1 ; src1src2 unsigned + jb l1 ; src1src2 returns 1, otherwise returns -1. + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int _CompareUnsArr(src1, src2, n) +unsigned SHORT src1[], src2[]; +int n; +{ + int i,result; + + result=0; + + for (i=n-1;(i>=0)&&(result==0);i--) + { + if (src1[i]!=src2[i]) + { + result = ( src1[i]>src2[i] ? 1 : -1 ); + } + } + + return(result); + +} diff --git a/gfm/gf.h b/gfm/gf.h new file mode 100755 index 000000000..c1bf6a942 --- /dev/null +++ b/gfm/gf.h @@ -0,0 +1,86 @@ +/* GF.H - Supports LARGE model */ +#define _LDATA 1 +#define _LCODE 1 +#ifndef _MSC +#define _MSC 5 +#endif +/* Required GF.H Header for Microsoft C +* +* Copyright (C) 1983-89 Greenleaf Software, Inc. All rights reserved. +* +* To use, copy this file, GF.S to GF.H +*/ + + + +#ifndef GFDOTH +#define GFDOTH + +#ifndef LINT_ARGS +#define LINT_ARGS +#endif + +#define GF_CDECL /*cdecl eliminato */ + +#define EOS '\0' +#ifdef M_I386 +typedef unsigned short word; +#else +typedef unsigned int word; +#endif +#ifndef GLOS2 +typedef char BYTE; +#endif +typedef int mbool; +#define VIDEO 0x10 +#define DOSINT 0x21 +struct GFREGS { int ax,bx,cx,dx,si,di,ds,es; }; +#define YES 1 +#define NO 0 +#ifndef TRUE + #define TRUE 1 +#endif +#ifndef FALSE + #define FALSE 0 +#endif +#ifndef OK + #define OK 1 +#endif +#define NOTOK 0 +#define SUCCESS 1 +#define FAILURE 0 +#ifndef ON + #define ON 1 +#endif +#ifndef OFF + #define OFF 0 +#endif +#define SET 1 +#define CLEAR 0 +#define FOREVER 1 +#define NEVER 0 +#define ERROR (-1) +#define NORM 1 +#define FAST 2 +#define SLOW 3 +#define INCHES 10 +#define LINES 11 +#define BLANK 0x20 +#define CR 13 +#define LF 10 +#define FF 12 +#define BKSP 8 +#define TAB 9 +#define ESC 27 +#define DEL 0x7F +/* monochrome video attributes */ +#define ULINE 1 +#define INTENSE 8 +#define NORMAL 7 +#define VNORMAL 7 +#define REVERSE 0x70 +#define NONDISP 0 +#define iscarry(x) ((x&0x0001)?TRUE:FALSE) + +#endif + diff --git a/gfm/gfd.h b/gfm/gfd.h new file mode 100755 index 000000000..5a151a8ea --- /dev/null +++ b/gfm/gfd.h @@ -0,0 +1,25 @@ +#ifndef __GFD_H +#define __GFD_H + +typedef struct idec { + SHORT attr; + SHORT id; + unsigned SHORT sl[4]; /* 80-bit signed number */ + short msd; /* most significant word */ + } IDEC; + +typedef struct ldec { + SHORT lattr; /* redef's for long's */ + SHORT lid; + unsigned long lsl[2]; + short lmsd; + } LDEC; + +typedef union { + IDEC dc; + LDEC ls; + } DEC; + +typedef DEC DECP[1]; + +#endif /* __GFD_H */ diff --git a/gfm/gfmdefs.c b/gfm/gfmdefs.c new file mode 100755 index 000000000..e8e937817 --- /dev/null +++ b/gfm/gfmdefs.c @@ -0,0 +1,8 @@ +/* + Definition file for shared library, initializing pointers to imported + functions. +*/ + +int (*_libgfm_scanf)() = 0; +int (*_libgfm_fscanf)() = 0; +int (*_libgfm_sscanf)() = 0; diff --git a/gfm/ginc.asm b/gfm/ginc.asm new file mode 100755 index 000000000..8a88ea78e --- /dev/null +++ b/gfm/ginc.asm @@ -0,0 +1,61 @@ + ; void _IncrementUnsArr(a) + ; + ; ARGUMENT + ; unsigned *a; + ; + ; DESCRIPTION + ; given the address of a unsigned array, increment the + ; number and return the result to the structure. + ; + ; SIDE EFFECTS + ; None. + ; + ; RETURNS + ; None. (assume no overflow) + ; + ; AUTHOR + ; Andy Anderson 13-JAN-1987 16:30 + ; Copyright (C) 1987-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; aa 08-JUL-87 n-bit + ; + ; jl 7/12/89 sped up, removed n parameter + + include model.h + include prologue.h + include gm.equ + + + pseg gmath +; +; if large memory model then: +; +; parm1_ = ptr to source 1 +; +; for if small model then +; parm1_ = ptr to source1 +; + cproc _IncrementUnsArr,,_ginc + +if _LDATA + push ds + lds si,parm1_ ; ptr to a +else + mov si,parm1_ +endif + +inclp: + inc word ptr [si] + jnz exit + inc si + inc si + jmp short inclp + +exit: +if _LDATA + pop ds +endif + cproce + endps + END diff --git a/gfm/ginc.c b/gfm/ginc.c new file mode 100755 index 000000000..3f9e4887a --- /dev/null +++ b/gfm/ginc.c @@ -0,0 +1,40 @@ +/* void _IncrementUnsArr(a) + * + * ARGUMENT + * unsigned a[]; + * + * DESCRIPTION + * Increments the number a (Adds 1 to a). + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None (assume no overflow) + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + + +void _IncrementUnsArr(a) +unsigned SHORT a[]; +{ + int i; + + i=0; + + do + { + a[i]++; + } + while (a[i++]==0); + +} diff --git a/gfm/gl.c b/gfm/gl.c new file mode 100755 index 000000000..34c59fea7 --- /dev/null +++ b/gfm/gl.c @@ -0,0 +1,13 @@ +#include +#include "gm.h" + +main() +{ + int i; + char a[20]; + char b[20]; + + strcpy(b,"%s"); + i=_ScanfAux(1,a,b); + printf("%d\n",i); +} diff --git a/gfm/gm.equ b/gfm/gm.equ new file mode 100755 index 000000000..c984e2bad --- /dev/null +++ b/gfm/gm.equ @@ -0,0 +1,45 @@ +; gm.equ +; +; ARGUMENT +; Used as include file for assembly language modules +; +; DESCRIPTION +; Contains the precision and number of digits descriptors +; +; SIDE EFFECTS +; None. +; +; RETURNS +; N/A. +; +; AUTHOR +; Andy Anderson 05-JAN-1987 17:30 +; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved. +; +; MODIFICATIONS +; + +GM_SUCCESS EQU 0 +GM_FAILURE EQU 1 +TRUE EQU 1 +FALSE EQU 0 +YES EQU 1 +NO EQU 0 + +GM_BASE equ -300 +GM_NULLPOINTER equ GM_BASE - 1 ; function handed NULL ptr +GM_NULLSTRING equ GM_BASE - 2 ; function handed ptr to NULL str +GM_PILLPTYPE equ GM_BASE - 3 ; illegal pointer type +GM_OVERFLOW equ GM_BASE - 4 ; arithmetic overflow +GM_UNDERFLOW equ GM_BASE - 5 ; arithmetic underflow +GM_TRUNC equ GM_BASE - 6 ; lsd truncation: warning +GM_TRUNS equ GM_BASE - 7 ; no. too large for dest string +GM_NAN equ GM_BASE - 8 ; Not A Number: ptr to bad struct +GM_CNVRE equ GM_BASE - 9 ; fatal error during conversion +GM_CNVRW equ GM_BASE - 10 ; warning during conversion +GM_DIV0 equ GM_BASE - 11 ; attempt to divide by zero +GM_PWR0 equ GM_BASE - 12 ; zero to a power error +GM_IMAG equ GM_BASE - 13 ; imaginary number, eg sqrt(-1) +GM_NOMEMORY equ GM_BASE - 14 ; when calloc() fails +GM_INVALIDID equ GM_BASE - 15 ; when given 0>id>18 & not=GM_AUTO +GM_NOTFOUND equ GM_BASE - 16 ; list comparison crit not fnd diff --git a/gfm/gm.h b/gfm/gm.h new file mode 100755 index 000000000..219233a08 --- /dev/null +++ b/gfm/gm.h @@ -0,0 +1,136 @@ +/* General includes for Greenleaf Financial MathLib +* +* Include this file with ALL programs using the MathLib. +* Contains error code definitions and numerous globals +* +* Copyright (C) 1986-1990 Greenleaf Software Inc. All rights reserved. +*/ + +#ifndef GMDOTH +#define GMDOTH + +#include + +/* including gf.h must come first!!*/ +#ifndef GFDOTH +#include +#endif + +#define MATHLIB_VERSION 110 + +#ifndef LINT +#include +#endif + +#define GM_SUCCESS 0 +#define GM_FAILURE 1 +#define GM_POS 0 +#define GM_NEG 0x0001 +#define GM_MAXID 18 +#define GM_MINID 0 +#define GM_DEQ 0 /* case criteria */ +#define GM_DGEQ 1 /* arguments for */ +#define GM_DLEQ -1 /* list */ +#define GM_DLT -2 /* comparsion */ +#define GM_DGT 2 /* functions like */ +#define GM_DNE 3 /* dcmplst() */ +#define GM_INC 1 +#define GM_DEC 2 +#define GM_N 0 /* next 4 used by SimpleInterest36x */ +#define GM_I 1 +#define GM_PV 2 +#define GM_INTR 3 +#define GM_PMT 4 /* next 4 used by compound interest */ +#define GM_FV 5 +#define GM_BEGIN 1 +#define GM_END 2 +#define GM_CONTINUOUS -1 /* used by nomtoeff & efftonom */ + +#define GM_BASE -300 +#define GM_NULLPOINTER GM_BASE - 1 /* Null pointer to DEC structure */ +#define GM_NULLSTRING GM_BASE - 2 /* Null pointer to string passed */ +#define GM_INIT GM_BASE - 3 /* Uninitialized input DEC */ +#define GM_OVERFLOW GM_BASE - 4 /* Arithmetic overflow occured */ +#define GM_UNDERFLOW GM_BASE - 5 /* Arithmetic underflow occured */ +#define GM_NAN GM_BASE - 6 /* Ptr or result is Not A Number */ +#define GM_CNVRE GM_BASE - 7 /* Significant digits trunc on conv */ +#define GM_CNVRW GM_BASE - 8 /* Insignif digits trunc on conv */ +#define GM_DIV0 GM_BASE - 9 /* Attempted divide by zero */ +#define GM_PWR0 GM_BASE - 10 /* Attempted raising zero to power */ +#define GM_IMAG GM_BASE - 11 /* Imaginary result, eg sqrt(-1) */ +#define GM_NOMEMORY GM_BASE - 12 /* when calloc() fails */ +#define GM_INVALIDID GM_BASE - 13 /* invalid ID range passed to () */ +#define GM_NOTFOUND GM_BASE - 14 /* list criteria not found */ +#define GM_ARGVAL GM_BASE - 15 /* Bad Argument value */ +#define GM_EOF GM_BASE - 16 /* File read/write problems */ + +#ifdef _LDATA +#define GM_NULL (DEC *) 0L +#define GM_NULLARR (DEC **) 0L +#else +#define GM_NULL (DEC *) 0 +#define GM_NULLARR (DEC **) 0 +#endif + +#ifndef NULLF +#define NULLF (int (*)()) 0 +#endif + +#ifndef GFDECL +#include +#endif + +/* these MUST BE IN THIS ORDER */ +#include +#include + +extern int wGMError; /* global error variable */ + +extern void (*pfnGMErrVector)(int, int); /* ptr to error handler */ +void GMDefErrHandler(int,int); /* name of error handler */ +extern int wGMFunErrNum; /* func number setting wGMError */ + +/* global storage for internal use */ +extern int wGMTemp1; /* temporary global storage */ +extern int wGMTemp2; +extern mbool wfGMRound; /* these 3 used for formatted conversions */ +extern mbool wfFlagNumber; +extern char cGMSymExp; +extern int wGMStar; /* storage of * arguments for dtoaf */ +extern int wGMStar2; +extern char cGMFmt; /* next 6 format string types */ +extern char cGMFmtComma; +extern char cGMFmtSci; +extern char cGMFmtSciE; +extern char cGMFmtEng; +extern char cGMFmtEngE; +extern DEC *pGMStatA; /* linear estimation */ +extern DEC *pGMStatB; +extern char cGMFmtRnd; +extern char cGMFmtTrunc; +extern char cGMFmtDlr; +extern char cGMFmtNegRgt1; +extern char cGMFmtNegRgt2; +extern char cGMFmtNegPar; +extern char cGMFmtNegBrkt; +extern char cGMFmtZeroBlC; +extern char cGMFmtZeroBlS; +extern char cGMFmtZero; +extern char *sGMFmtZeroStr; +extern char cGMFmtSurrL; +extern char cGMFmtSurrR; +extern char *sGMFmt1Pos; +extern char *sGMFmt1Neg; +extern char *sGMFmt1Zero; +extern char *sGMFmt2Pos; +extern char *sGMFmt2Neg; +extern char *sGMFmt2Zero; +extern mbool wfGM3Color; /* next 4 for 3-Color Interface Output */ +extern char cGMCodePos; +extern char cGMCodeNeg; +extern char cGMCodeNon; +extern int wIntrPrec; +extern DEC *pGMIRRGuess; + +#define SetMathError(a,b) (*pfnGMErrVector)(a,b) +#endif diff --git a/gfm/gmec.c b/gfm/gmec.c new file mode 100755 index 000000000..2838b5b3a --- /dev/null +++ b/gfm/gmec.c @@ -0,0 +1,49 @@ +/* int ReturnMathErrAndClear(); + * + * ARGUMENT + * + * + * DESCRIPTION + * Sets wGMError to GM_SUCCESS, and returns it's previous value. + * + * SIDE EFFECTS + * Does NOT clear the variable wGMErrFunNum (function number + * causing error). This is so that ReturnErrFuncNumAndClear() can + * get and clear that one separately. If you want to write your own + * functions, or do your own checking, remember that wGMErrFunNum + * may contain an error function number, but wGMError could have + * been cleared by some previous call to here. Function ClearMathError() + * unconditionally clears both and can be found in "gm.h". BE SURE YOU ARE + * A SOURCE CODE USER AND KNOW WHAT YOU ARE DOING WITH THESE + * VARIABLES, AND HOW THEY ARE AFFECTED BY THE INTERNAL ROUTINES, + * BEFORE YOU WRITE YOUR OWN ERROR HANDLER! + * + * RETURNS + * Returns value of wGMError (before settting it to GM_SUCCESS). + * + * POSSIBLE ERROR CODES + * + * None. + * + * AUTHOR + * Andy Anderson 19-FEB-1987 15:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int ReturnMathErrAndClear() +{ + + int i; + + i=wGMError; + wGMError = GM_SUCCESS; + _wGMUser = 0; + return(i); +} diff --git a/gfm/gmef.c b/gfm/gmef.c new file mode 100755 index 000000000..bd22cbe11 --- /dev/null +++ b/gfm/gmef.c @@ -0,0 +1,47 @@ +/* int ReturnErrFuncNumAndClear() + * + * ARGUMENT + * + * + * DESCRIPTION + * Sets wGMFunErrNum to 0, and returns it's previous value. + * + * SIDE EFFECTS + * Does NOT clear the variable wGMError (global error number). + * See ReturnMathErrAndClear() for that discussion. If you want to + * write your own functions, or do your own checking, remember that + * wGMFunErrNum may contain an error function number, but wGMError could + * have been cleared by some previous call to ReturnMathErrAndClear(). + * Function ClearMathError() unconditionally clears both and can be found + * in "gm.h". BE SURE YOU ARE A SOURCE CODE USER AND KNOW WHAT YOU ARE + * DOING WITH THESE VARIABLES, AND HOW THEY ARE EFFECTED BY THE INTERNAL + * ROUTINES, BEFORE YOU WRITE YOUR OWN ERROR HANDLER! + * + * RETURNS + * Returns value of wGMFunErrNum. + * + * POSSIBLE ERROR CODES + * + * None. + * + * AUTHOR + * Andy Anderson 19-FEB-1987 15:30 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +int ReturnErrFuncNumAndClear() +{ + int i; + + i=wGMFunErrNum; + wGMFunErrNum = 0; + _wGMUser=0; + return(i); +} diff --git a/gfm/gmfequs.h b/gfm/gmfequs.h new file mode 100755 index 000000000..02910b8f0 --- /dev/null +++ b/gfm/gmfequs.h @@ -0,0 +1,203 @@ +/* Greenleaf Financial MathLib +* Greenleaf Software, Inc. +* Long Names and Short Names equal so the user can +* Use the One they want (or intermix)... +* Copyright (c) 1984-1990 Greenleaf Software, Inc. All Rights Reserved. +* Function Call Equates that offer the user +* a shorter name to use in calling the mathlib. Note +* that it is the longer names that are actually in the +* .obj and .lib files. +*/ + +#define adate360 AddDaysToDate360 +#define adate365 AddDaysToDate365 +#define adatenly AddDaysToDate365NoLeapYear +#define addarr AddDecimalArrays +#define addarrd AddDecimalToDecimalArray +#define adddfd AddDoubleToDecimal +#define addid AddIntToDecimal +#define addld AddLongToDecimal +#define daddstr AddAscii +#define adduid AddUnsToDecimal +#define adduld AddUnsLongToDecimal +#define advpmt AdvancePayment +#define amort Amortize +#define amorttbl AmortizeTable +#define atod ConvAsciiToDecimal +#define atodr ConvAsciiToDecimalRound +#define comp CompoundInterest +#define compcomp CompoundInterestCompound +#define compsimp CompoundInterestSimple +#define dabs AbsoluteDecimal +#define dacos ArcCosineDecimal +#define dadd AddDecimal +#define dalloc AllocateDecimal +#define dalog AntiLog10Decimal +#define daralloc AllocateDecimalArray +#define darcpy CopyDecimalArray +#define darfree FreeDecimalArray +#define dasin ArcSineDecimal +#define datan ArcTangentDecimal +#define dbd360 DaysBetweenDates360 +#define dbd365 DaysBetweenDates365 +#define dbdnly DaysBetweenDates365NoLeapYear +#define dchgs ChangeSignDecimal +#define dcmp CompareDecimal +#define dcos CosineDecimal +#define dcot CotangentDecimal +#define dcpy CopyDecimal +#define dctod ConvDollarsAndCentsToDecimal +#define ddeg ConvRadiansToDegrees +#define ddiv DivideDecimal +#define ddivr DivideDecimalAndRound +#define ddivt DivideDecimalAndTruncate +#define deltrz DeleteTrailingZeroes +#define dexp AntiLogEDecimal +#define dfact Factorial +#define dfprintf FilePrintDecimal +#define dfract FractionDecimal +#define dfree FreeDecimal +#define dfscanf FileScanDecimal +#define dftod ConvDoubleToDecimal +#define dftodr ConvDoubleToDecimalRound +#define dint IntegerPartDecimal +#define diseq IsDecimalEqual +#define disge IsDecimalGreaterOrEqual +#define disgt IsDecimalGreater +#define disint IsDecimalInt +#define disle IsDecimalLessOrEqual +#define dislt IsDecimalLess +#define disne IsDecimalNotEqual +#define disneg IsDecimalNegative +#define dispos IsDecimalPositive +#define diszero IsDecimalZero +#define divarr DivideDecimalArrays +#define divarrd DivideDecimalArrayByDecimal +#define divdfd DivideDecimalByDouble +#define divid DivideDecimalByInt +#define divld DivideDecimalByLong +#define divstr DivideAscii +#define divuid DivideDecimalByUns +#define divuld DivideDecimalByUnsLong +#define dln LogEDecimal +#define dlog Log10Decimal +#define dmag MagnitudeOfDecimal +#define dmant DecimalMantissa +#define dmax MaximumDecimal +#define dmean StatMean +#define dmin MinimumDecimal +#define dmod ModuloDecimal +#define dmoddf DecimalModuloDouble +#define dmodi DecimalModuloInt +#define dmodl DecimalModuloLong +#define dmodui DecimalModuloUns +#define dmodul DecimalModuloUnsLong +#define dmul MultiplyDecimal +#define dmulr MultiplyDecimalAndRound +#define dmult MultiplyDecimalAndTruncate +#define dpct DecimalPercentage +#define dpdb DepreciateDeclining +#define dpdbtbl DepreciateDecliningTable +#define dpddb DepreciateDoubleDeclining +#define dpddbtbl DepreciateDoubleDecliningTable +#define dpow PowerDecimal +#define dpowi PowerInteger +#define dpowrat PowerRational +#define dprec DecimalPrecision +#define dprintf PrintDecimal +#define dpsl DepreciateStraightLine +#define dpsltbl DepreciateStraightLineTable +#define dpsoy DepreciateSumOfYears +#define dpsoytbl DepreciateSumOfYearsTable +#define drad ConvDegreesToRadians +#define droot RootDecimal +#define drooti RootInteger +#define dround RoundDecimal +#define dscanf ScanDecimal +#define dsetertn SetMathErrVector +#define dsign TestSignDecimal +#define dsin SineDecimal +#define dsprintf StringPrintDecimal +#define dsqrt SquareRootDecimal +#define dsscanf StringScanDecimal +#define dsub SubtractDecimal +#define dtan TangentDecimal +#define dtoa ConvDecimalToAscii +#define dtoac ConvDecimalToAsciiComma +#define dtoacr ConvDecimalToAsciiCommaRound +#define dtoar ConvDecimalToAsciiRound +#define dtodc ConvDecimalToDollarsAndCents +#define dtodf ConvDecimalToDouble +#define dtoeng ConvDecimalToEngineering +#define dtofr ConvDecimalToFraction +#define dtoi ConvDecimalToInt +#define dtol ConvDecimalToLong +#define dtosci ConvDecimalToScientific +#define dtoui ConvDecimalToUns +#define dtoul ConvDecimalToUnsLong +#define dtrunc TruncateDecimal +#define dzero ZeroDecimal +#define dzeroarr ZeroDecimalArray +#define efftonom ConvEffectiveToNominal +#define errname ErrorName +#define frtod ConvFractionToDecimal +#define funname FunctionName +#define gmec ReturnMathErrAndClear +#define gmef ReturnErrFuncNumAndClear +#define gmrs ClearMathError +#define irr InternalRateOfReturn +#define itod ConvIntToDecimal +#define linest LinearEstimate +#define lookarr LookUpDecimalArray +#define ltod ConvLongToDecimal +#define makid MakeDecimalFromInt +#define makld MakeDecimalFromLong +#define makuid MakeDecimalFromUns +#define makuld MakeDecimalFromUnsLong +#define maxarr FindMaximumDecimalArray +#define minarr FindMinimumDecimalArray +#define mirr ModifiedIRR +#define mularr MultiplyDecimalArrays +#define mularrd MultiplyDecimalArrayByDecimal +#define muldfd MultiplyDecimalByDouble +#define mulid MultiplyDecimalByInt +#define mulld MultiplyDecimalByLong +#define mulstr MultiplyAscii +#define muluid MultiplyDecimalByUns +#define mululd MultiplyDecimalByUnsLong +#define nfv NetFutureValue +#define nomtoeff ConvNominalToEffective +#define npv NetPresentValue +#define padd AddPercent +#define pchange PercentChange +#define pdiv DividePercent +#define pmul MultiplyPercent +#define pof PercentOf +#define predx PredictX +#define predy PredictY +#define psub SubtractPercent +#define ptoy ConvPeriodicToYearly +#define roundcnt RoundCents +#define simp360 SimpleInterest360 +#define simp365 SimpleInterest365 +#define spfv SinglePaymentFutureValue +#define sppv SinglePaymentPresentValue +#define stnddev StandardDeviation +#define subarr SubtractDecimalArrays +#define subarrd SubtractDecimalFromDecimalArray +#define subdfd SubtractDoubleFromDecimal +#define subid SubtractIntFromDecimal +#define subld SubtractLongFromDecimal +#define substr SubtractAscii +#define subuid SubtractUnsFromDecimal +#define subuld SubtractUnsLongFromDecimal +#define sumarr SumDecimalArray +#define sumarrn SumDecimalArrayNegative +#define sumarrp SumDecimalArrayPositive +#define trunccnt TruncateCents +#define uitod ConvUnsToDecimal +#define ultod ConvUnsLongToDecimal +#define usfv UniformSeriesFutureValue +#define uspv UniformSeriesPresentValue +#define wmean WeightedMean +#define ytop ConvYearlyToPeriodic diff --git a/gfm/gmfname.h b/gfm/gmfname.h new file mode 100755 index 000000000..7c7a33eec --- /dev/null +++ b/gfm/gmfname.h @@ -0,0 +1,208 @@ +/* + + Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + + This is a list of the function names as strings for use by FunctionName() + To give correct results, gmfname.h, gmfequs.h, & gmfncnum.h must list the + same functions in the same order. */ + +static char *fnames[]={ +"None", +"AddDaysToDate360", +"AddDaysToDate365", +"AddDecimalArrays", +"AddDecimalToDecimalArray", +"AddDoubleToDecimal", +"AddIntToDecimal", +"AddLongToDecimal", +"AddAscii", +"AddUnsToDecimal", +"AddUnsLongToDecimal", +"AdvancedPayment", +"Amortize", +"AmortizeTable", +"ConvAsciiToDecimal", +"ConvAsciiToDecimalRound", +"BondPrice", +"BondYield", +"CompoundInterest", +"CompoundInterestCompound", +"CompoundInterestSimple", +"AbsoluteDecimal", +"ArcCosineDecimal", +"AddDecimal", +"AllocateDecimal", +"AntiLog10Decimal", +"AllocateDecimalArray", +"CopyDecimalArray", +"FreeDecimalArray", +"ArcSineDecimal", +"ArcTangentDecimal", +"DaysBetweenDates360", +"DaysBetweenDates365", +"ChangeSignDecimal", +"CompareDecimal", +"CosineDecimal", +"CotangentDecimal", +"CopyDecimal", +"ConvRadiansToDegrees", +"DivideDecimal", +"DivideDecimalAndRound", +"DivideDecimalAndTruncate", +"DeleteTrailingZeroes", +"AntiLogEDecimal", +"Factorial", +"FilePrintDecimal", +"FractionDecimal", +"FreeDecimal", +"FileScanDecimal", +"ConvDoubleToDecimal", +"ConvDoubleToDecimalRound", +"IntegerPartDecimal", +"IsDecimalEqual", +"IsDecimalGreaterOrEqual", +"IsDecimalGreater", +"IsDecimalInt", +"IsDecimalLessOrEqual", +"IsDecimalLess", +"IsDecimalNotEqual", +"IsDecimalNegative", +"IsDecimalPositive", +"IsDecimalZero", +"DivideDecimalArrays", +"DivideDecimalArrayByDecimal", +"DivideDecimalByDouble", +"DivideDecimalByInt", +"DivideDecimalByLong", +"DivideAscii", +"DivideDecimalByUns", +"DivideDecimalByUnsLong", +"LogEDecimal", +"Log10Decimal", +"MagnitudeOfDecimal", +"DecimalMantissa", +"MaximumDecimal", +"StatMean", +"MinimumDecimal", +"ModuloDecimal", +"DecimalModuloDouble", +"DecimalModuloInt", +"DecimalModuloLong", +"DecimalModuloUns", +"DecimalModuloUnsLong", +"MultiplyDecimal", +"MultiplyDecimalAndRound", +"MultiplyDecimalAndTruncate", +"DecimalPercentage", +"DepreciateDeclining", +"DepreciateDecliningTable", +"DepreciateDoubleDeclining", +"DepreciateDoubleDecliningTable", +"PowerDecimal", +"PowerInteger", +"PowerRational", +"DecimalPrecision", +"PrintDecimal", +"DepreciateStraightLine", +"DepreciateStraightLineTable", +"DepreciateSumOfYears", +"DepreciateSumOfYearsTable", +"ConvDegreesToRadians", +"RootDecimal", +"RootInteger", +"RoundDecimal", +"ScanDecimal", +"SetMathErrVector", +"TestSignDecimal", +"SineDecimal", +"SortDecimalArray", +"StringPrintDecimal", +"SquareRootDecimal", +"StringScanDecimal", +"SubtractDecimal", +"SwapDecimal", +"TangentDecimal", +"ConvDecimalToAscii", +"ConvDecimalToAsciiComma", +"ConvDecimalToAsciiCommaRound", +"ConvDecimalToAsciiRound", +"ConvDecimalToDouble", +"ConvDecimalToEngineering", +"ConvDecimalToInt", +"ConvDecimalToLong", +"ConvDecimalToScientific", +"ConvDecimalToUns", +"ConvDecimalToUnsLong", +"TruncateDecimal", +"ZeroDecimal", +"ZeroDecimalArray", +"ConvEffectiveToNominal", +"ErrorName", +"FunctionName", +"ReturnMathErrAndClear", +"ReturnErrFuncNumAndClear", +"ClearMathError", +"InternalRateOfReturn", +"ConvIntToDecimal", +"LinearEstimate", +"LookUpDecimalArray", +"ConvLongToDecimal", +"MakeDecimalFromInt", +"MakeDecimalFromLong", +"MakeDecimalFromUns", +"MakeDecimalFromUnsLong", +"FindMaximumDecimalArray", +"Median", +"FindMinimumDecimalArray", +"ModifiedIRR", +"MultiplyDecimalArrays", +"MultiplyDecimalArrayByDecimal", +"MultiplyDecimalByDouble", +"MultiplyDecimalByInt", +"MultiplyDecimalByLong", +"MultiplyAscii", +"MultiplyDecimalByUns", +"MultiplyDecimalByUnsLong", +"NetFutureValue", +"ConvNominalToEffective", +"NetPresentValue", +"AddPercent", +"PercentChange", +"DividePercent", +"MultiplyPercent", +"PercentOf", +"PredictX", +"PredictY", +"SubtractPercent", +"SimpleInterest360", +"SimpleInterest365", +"SinglePaymentFutureValue", +"SinglePaymentPresent", +"StandardDeviation", +"SubtractDecimalArrays", +"SubtractDecimalFromDecimalArray", +"SubtractDoubleFromDecimal", +"SubtractIntFromDecimal", +"SubtractLongFromDecimal", +"SubtractAscii", +"SubtractUnsFromDecimal", +"SubtractUnsLongFromDecimal", +"SumDecimalArray", +"SumDecimalArrayNegative", +"SumDecimalArrayPositive", +"ConvUnsToDecimal", +"ConvUnsLongToDecimal", +"UniformSeriesFutureValue", +"UniformSeriesPresentValue", +"WeightedMean", +"AddDaysToDate365NoLeapYear", +"DaysBetweenDates365NoLeapYear", +"ConvDollarsAndCentsToDecimal", +"ConvDecimalToDollarsAndCents", +"ConvDecimalToFraction", +"ConvFractionToDecimal", +"ConvPeriodicToYearly", +"RoundCents", +"TruncateCents", +"ConvYearlyToPeriodic" +}; diff --git a/gfm/gmfncnum.h b/gfm/gmfncnum.h new file mode 100755 index 000000000..ceee184dd --- /dev/null +++ b/gfm/gmfncnum.h @@ -0,0 +1,206 @@ +/* Function numbers for error system. +* Greenleaf Financial MathLib +* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reservd. +*/ +typedef enum func_names { + GM_FN_BASE, + GM_ADATE360, + GM_ADATE365, + GM_ADDARR, + GM_ADDARRD, + GM_ADDDFD, + GM_ADDID, + GM_ADDLD, + GM_ADDSTR, + GM_ADDUID, + GM_ADDULD, + GM_ADVPMT, + GM_AMORT, + GM_AMORTTBL, + GM_ATOD, + GM_ATODR, + GM_BONDPRC, + GM_BONDYLD, + GM_COMP, + GM_COMPCOMP, + GM_COMPSIMP, + GM_DABS, + GM_DACOS, + GM_DADD, + GM_DALLOC, + GM_DALOG, + GM_DARALLOC, + GM_DARCPY, + GM_DARFREE, + GM_DASIN, + GM_DATAN, + GM_DBD360, + GM_DBD365, + GM_DCHGS, + GM_DCMP, + GM_DCOS, + GM_DCOT, + GM_DCPY, + GM_DDEG, + GM_DDIV, + GM_DDIVR, + GM_DDIVT, + GM_DELTRZ, + GM_DEXP, + GM_DFACT, + GM_DFPRINTF, + GM_DFRACT, + GM_DFREE, + GM_DFSCANF, + GM_DFTOD, + GM_DFTODR, + GM_DINT, + GM_DISEQ, + GM_DISGE, + GM_DISGT, + GM_DISINT, + GM_DISLE, + GM_DISLT, + GM_DISNE, + GM_DISNEG, + GM_DISPOS, + GM_DISZERO, + GM_DIVARR, + GM_DIVARRD, + GM_DIVDFD, + GM_DIVID, + GM_DIVLD, + GM_DIVSTR, + GM_DIVUID, + GM_DIVULD, + GM_DLN, + GM_DLOG, + GM_DMAG, + GM_DMANT, + GM_DMAX, + GM_DMEAN, + GM_DMIN, + GM_DMOD, + GM_DMODDF, + GM_DMODI, + GM_DMODL, + GM_DMODUI, + GM_DMODUL, + GM_DMUL, + GM_DMULR, + GM_DMULT, + GM_DPCT, + GM_DPDB, + GM_DPDBTBL, + GM_DPDDB, + GM_DPDDBTBL, + GM_DPOW, + GM_DPOWI, + GM_DPOWRAT, + GM_DPREC, + GM_DPRINTF, + GM_DPSL, + GM_DPSLTBL, + GM_DPSOY, + GM_DPSOYTBL, + GM_DRAD, + GM_DROOT, + GM_DROOTI, + GM_DROUND, + GM_DSCANF, + GM_DSETERTN, + GM_DSIGN, + GM_DSIN, + GM_DSORT, + GM_DSPRINTF, + GM_DSQRT, + GM_DSSCANF, + GM_DSUB, + GM_DSWAP, + GM_DTAN, + GM_DTOA, + GM_DTOAC, + GM_DTOACR, + GM_DTOAR, + GM_DTODF, + GM_DTOENG, + GM_DTOI, + GM_DTOL, + GM_DTOSCI, + GM_DTOUI, + GM_DTOUL, + GM_DTRUNC, + GM_DZERO, + GM_DZEROARR, + GM_EFFTONOM, + GM_ERRNAME, + GM_FUNNAME, + GM_GMEC, + GM_GMEF, + GM_GMRS, + GM_IRR, + GM_ITOD, + GM_LINEST, + GM_LOOKARR, + GM_LTOD, + GM_MAKID, + GM_MAKLD, + GM_MAKUID, + GM_MAKULD, + GM_MAXARR, + GM_MEDIAN, + GM_MINARR, + GM_MIRR, + GM_MULARR, + GM_MULARRD, + GM_MULDFD, + GM_MULID, + GM_MULLD, + GM_MULSTR, + GM_MULUID, + GM_MULULD, + GM_NFV, + GM_NOMTOEFF, + GM_NPV, + GM_PADD, + GM_PCHANGE, + GM_PDIV, + GM_PMUL, + GM_POF, + GM_PREDX, + GM_PREDY, + GM_PSUB, + GM_SIMP360, + GM_SIMP365, + GM_SPFV, + GM_SPPV, + GM_STNDDEV, + GM_SUBARR, + GM_SUBARRD, + GM_SUBDFD, + GM_SUBID, + GM_SUBLD, + GM_SUBSTR, + GM_SUBUID, + GM_SUBULD, + GM_SUMARR, + GM_SUMARRN, + GM_SUMARRP, + GM_UITOD, + GM_ULTOD, + GM_USFV, + GM_USPV, + GM_WMEAN, + GM_ADATENLY, + GM_DBDNLY, + GM_DCTOD, + GM_DTODC, + GM_DTOFR, + GM_FRTOD, + GM_ROUNDCNT, + GM_PTOY, + GM_TRUNCCNT, + GM_YTOP, + GM_ZZZ +} MathFunNumList; +#define GM_FN_NUM (GM_ZZZ - GM_FN_BASE - 1) diff --git a/gfm/gmfuncts.h b/gfm/gmfuncts.h new file mode 100755 index 000000000..09374c63d --- /dev/null +++ b/gfm/gmfuncts.h @@ -0,0 +1,235 @@ +/* Greenleaf Financial MathLib +* Function Call Prototypes +* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. +*/ +#ifndef FILE +#include +#endif + +#ifdef __cplusplus +#define ELLIPSES ... +extern "C" { +#else +#if defined(__GNUC__) || defined(__WATCOMC__) || defined(__TURBOC__) +#define ELLIPSES ... +#else +#define ELLIPSES +#endif +#endif + +DEC *AbsoluteDecimal( DEC *, DEC * ); +DEC *AddAscii( DEC *, char *, char * ); +void AddsToDate360( int *, int *, int *, int , int , int , int ); +void AddsToDate365( int *, int *, int *, int , int , int , int ); +void AddsToDate365NoLeap( int *, int *, int *, int , int , int , int ); +DEC *AddDecimal( DEC *, DEC *, DEC * ); +DEC **AddDecimalArrays( DEC *[], DEC *[], DEC *[], int ); +DEC **AddDecimalToDecimalArray( DEC *[], DEC *[], DEC *, int ); +DEC *AddDoubleToDecimal( DEC *, DEC *, double ); +DEC *AddIntToDecimal( DEC *, DEC *, int ); +DEC *AddLongToDecimal( DEC *, DEC *, long ); +DEC *AddPercent( DEC *, DEC *, DEC *); +DEC *AddUnsLongToDecimal( DEC *, DEC *, unsigned long ); +DEC *AddUnsToDecimal( DEC *, DEC *, unsigned int ); +DEC *AdvancePayment( int , DEC *, DEC *, DEC *, DEC *, int , int ); +DEC *AllocateDecimal( void ); +DEC* *AllocateDecimalArray( DEC *[], int ); +void Amortize( DEC *, DEC *, DEC *, DEC *, DEC *, DEC *, int , int ); +void AmortizeTable( DEC *[], DEC *[], DEC *[], DEC *, DEC *, DEC *, + int , int ); +DEC *AntiLog10Decimal( DEC *, DEC * ); +DEC *AntiLogEDecimal( DEC *, DEC * ); +DEC *ArcCosineDecimal( DEC *, DEC *); +DEC *ArcSineDecimal( DEC *, DEC *); +DEC *ArcTangentDecimal( DEC *, DEC *); +DEC *BondPrice( DEC *, DEC *, DEC *, DEC *, int , int , int , int , + int , int , int ); +DEC *BondYield( DEC *, DEC *, DEC *, int , int , int , int , int , + int , int ); +DEC *ChangeSignDecimal( DEC *, DEC * ); +void ClearMathError( void ); +int CompareDecimal( DEC *, DEC * ); +DEC *CompoundInterest( int *, DEC *, DEC *, DEC *, DEC *, int , int ); +DEC *CompoundInterestCompound( DEC *, DEC *, DEC *, DEC *, DEC *, int , + int ); +DEC *CompoundInterestSimple( DEC *, DEC *, DEC *, DEC *, DEC *, int , + int ); +DEC *ConvAsciiToDecimal( DEC *, char * ); +DEC *ConvAsciiToDecimalRound( DEC *, char *, int ); +char *ConvDecimalToAscii( char *, DEC * ); +char *ConvDecimalToAsciiComma(char *, DEC * ); +char *ConvDecimalToAsciiCommaRound( char *, DEC *, int ); +char *ConvDecimalToAsciiRound( char *, DEC *, int ); +long ConvDecimalToDollarsAnd( int *, DEC * ); +double ConvDecimalToDouble( DEC * ); +char *ConvDecimalToEngineering( char *, DEC *, int ); +long ConvDecimalToFraction( int *, DEC *, int ); +int ConvDecimalToInt( DEC * ); +long ConvDecimalToLong( DEC * ); +char *ConvDecimalToScientific( char *, DEC *, int ); +unsigned int ConvDecimalToUns( DEC * ); +unsigned long ConvDecimalToUnsLong( DEC * ); +DEC *ConvDegreesToRadians( DEC *, DEC * ); +DEC *ConvDollarsAndToDecimal( DEC *, long , int ); +DEC *ConvDoubleToDecimal( DEC *, double ); +DEC *ConvDoubleToDecimalRound( DEC *, double , int ); +DEC *ConvEffectiveToNominal( DEC *, DEC *, int ); +DEC *ConvFractionToDecimal( DEC *, long , int , int ); +DEC *ConvIntToDecimal( DEC *, int ); +DEC *ConvLongToDecimal( DEC *, long ); +DEC *ConvNominalToEffective( DEC *, DEC *, int ); +DEC *ConvPeriodicToly( DEC *, DEC *, int ); +DEC *ConvRadiansToDegrees( DEC *, DEC * ); +DEC *ConvUnsLongToDecimal( DEC *, unsigned long ); +DEC *ConvUnsToDecimal( DEC *, unsigned int ); +DEC *ConvlyToPeriodic( DEC *, DEC *, int ); +DEC *CopyDecimal( DEC *, DEC * ); +DEC **CopyDecimalArray( DEC *[], DEC *[], int ); +DEC *CosineDecimal( DEC *, DEC * ); +DEC *CotangentDecimal( DEC *, DEC * ); +int DaysBetweenDates360( int , int , int , int , int , int ); +int DaysBetweenDates365( int , int , int , int , int , int ); +int DaysBetweenDates365NoLeapYear( int , int , int , int , int , + int ); +long DecimalMantissa( DEC * ); +DEC *DecimalModuloDouble( DEC *, DEC *, double ); +DEC *DecimalModuloInt( DEC *, DEC *, int ); +DEC *DecimalModuloLong( DEC *, DEC *, long ); +DEC *DecimalModuloUns( DEC *, DEC *, unsigned int ); +DEC *DecimalModuloUnsLong( DEC *, DEC *, unsigned long ); +DEC *DecimalPercentage( DEC *, DEC *, int ); +int DecimalPrecision( DEC * ); +DEC *DeleteTrailingZeroes( DEC *, DEC * ); +DEC *DepreciateDeclining( DEC *, DEC *, DEC *, DEC *, DEC *, int , + DEC *, int ); +DEC* *DepreciateDecliningTable( DEC *[], DEC *[], DEC *, DEC *, DEC *, + int , DEC *); +DEC *DepreciateDoubleDeclining( DEC *, DEC *, DEC *, DEC *, int , + DEC *, int ); +DEC* *DepreciateDoubleDecliningTable( DEC *[], DEC *[], DEC *, DEC *, + int , DEC *); +DEC *DepreciateStraightLine( DEC *, DEC *, DEC *, DEC *, int , DEC *, + int ); +DEC* *DepreciateStraightLineTable( DEC *[], DEC *[], DEC *, DEC *, int , + DEC *); +DEC *DepreciateSumOfYears( DEC *, DEC *, DEC *, DEC *, int , DEC *, + int ); +DEC* *DepreciateSumOfYearsTable( DEC *[], DEC *[], DEC *, DEC *, int , + DEC *); +DEC *DivideAscii( DEC *, char *, char *); +DEC *DivideDecimal( DEC *, DEC *, DEC *); +DEC *DivideDecimalAndRound( DEC *, DEC *, DEC *, int ); +DEC *DivideDecimalAndTruncate( DEC *, DEC *, DEC *, int ); +DEC* *DivideDecimalArrayByDecimal( DEC *[], DEC *[], DEC *, int ); +DEC **DivideDecimalArrays( DEC *[], DEC *[], DEC *[], int ); +DEC *DivideDecimalByDouble( DEC *, DEC *, double ); +DEC *DivideDecimalByInt( DEC *, DEC *, int ); +DEC *DivideDecimalByLong( DEC *, DEC *, long ); +DEC *DivideDecimalByUns( DEC *, DEC *, unsigned int ); +DEC *DivideDecimalByUnsLong( DEC *, DEC *, unsigned long ); +DEC *DividePercent( DEC *, DEC *, DEC *); +char *ErrorName( char *, int ); +DEC *Factorial( DEC *, unsigned int ); +int FilePrintDecimal( FILE *, char *, ELLIPSES); +int FileScanDecimal( FILE *, char *, ELLIPSES); +DEC *FindMaximumDecimalArray( DEC *, DEC *[], int ); +DEC *FindMinimumDecimalArray( DEC *, DEC *[], int ); +DEC *FractionDecimal( DEC *, DEC * ); +void FreeDecimal( DEC * ); +void FreeDecimalArray( DEC *[] ); +char *FunctionName( char *, int ); +DEC *IntegerPartDecimal( DEC *, DEC * ); +DEC *InternalRateOfReturn( DEC *, DEC *[], int ); +int IsDecimalEqual( DEC *, DEC * ); +int IsDecimalGreater( DEC *, DEC * ); +int IsDecimalGreaterOrEqual( DEC *, DEC * ); +int IsDecimalInt( DEC * ); +int IsDecimalLess( DEC *, DEC * ); +int IsDecimalLessOrEqual( DEC *, DEC * ); +int IsDecimalNegative( DEC * ); +int IsDecimalNotEqual( DEC *, DEC * ); +int IsDecimalPositive( DEC * ); +int IsDecimalZero( DEC * ); +DEC *LinearEstimate( DEC *, DEC *, DEC *, DEC *[], DEC *[], int ); +DEC *Log10Decimal( DEC *, DEC * ); +DEC *LogEDecimal( DEC *, DEC * ); +int LookUpDecimalArray( DEC *[], DEC *, int , int ); +int MagnitudeOfDecimal( DEC * ); +DEC *MakeDecimalFromInt( DEC *, int , int ); +DEC *MakeDecimalFromLong( DEC *, long , int ); +DEC *MakeDecimalFromUns( DEC *, unsigned int , int ); +DEC *MakeDecimalFromUnsLong( DEC *, unsigned long , int ); +DEC *MaximumDecimal( DEC *, DEC *, DEC * ); +DEC *Median( DEC *, DEC *[], int ); +DEC *MinimumDecimal( DEC *, DEC *, DEC * ); +DEC *ModifiedIRR( DEC *, DEC *[], int , DEC *, DEC *); +DEC *ModuloDecimal( DEC *, DEC *, DEC *); +DEC *MultiplyAscii( DEC *, char *, char * ); +DEC *MultiplyDecimal( DEC *, DEC *, DEC * ); +DEC *MultiplyDecimalAndRound( DEC *, DEC *, DEC *, int ); +DEC *MultiplyDecimalAndTruncate( DEC *, DEC *, DEC *, int ); +DEC* *MultiplyDecimalArrayByDecimal( DEC *[], DEC *[], DEC *, int ); +DEC* *MultiplyDecimalArrays( DEC *[], DEC *[], DEC *[], int ); +DEC *MultiplyDecimalByDouble( DEC *, DEC *, double ); +DEC *MultiplyDecimalByInt( DEC *, DEC *, int ); +DEC *MultiplyDecimalByLong( DEC *, DEC *, long ); +DEC *MultiplyDecimalByUns( DEC *, DEC *, unsigned int ); +DEC *MultiplyDecimalByUnsLong( DEC *, DEC *, unsigned long ); +DEC *MultiplyPercent( DEC *, DEC *, DEC *); +DEC *NetFutureValue( DEC *, DEC *[], int , DEC *); +DEC *NetPresentValue( DEC *, DEC *[], int , DEC *); +DEC *PercentChange( DEC *, DEC *, DEC * ); +DEC *PercentOf( DEC *, DEC *, DEC * ); +DEC *PowerDecimal( DEC *, DEC *, DEC * ); +DEC *PowerInteger( DEC *, DEC *, int ); +DEC *PowerRational( DEC *, DEC *, int , int ); +DEC *PredictX( DEC *, DEC * ); +DEC *PredictY( DEC *, DEC * ); +int PrintDecimal( char *, ELLIPSES); +int ReturnErrFuncNumAndClear( void ); +int ReturnMathErrAndClear( void ); +DEC *RootDecimal( DEC *, DEC *, DEC *); +DEC *RootInteger( DEC *, DEC *, int ); +DEC *RoundCents( DEC *, DEC *, int ); +DEC *RoundDecimal( DEC *, DEC *, int ); +int ScanDecimal( char *, ELLIPSES); +void SetMathErrVector( void (*)( int , int ) ); +DEC *SimpleInterest360( int *, DEC *, DEC *, DEC *, int ); +DEC *SimpleInterest365( int *, DEC *, DEC *, DEC *, int ); +DEC *SineDecimal( DEC *, DEC *); +DEC *SinglePaymentFutureValue( DEC *, DEC *, int ); +DEC *SinglePaymentPresentValue( DEC *, DEC *, int ); +DEC **SortDecimalArray( DEC *[], DEC *[], int , int ); +DEC *SquareRootDecimal( DEC *, DEC * ); +DEC *StandardDeviation( DEC *, DEC *[], int ); +DEC *StatMean( DEC *, DEC *[], int ); +int StringPrintDecimal( char *, char *, ELLIPSES); +int StringScanDecimal( char *, char *, ELLIPSES); +DEC *SubtractAscii( DEC *, char *, char *); +DEC *SubtractDecimal( DEC *, DEC *, DEC * ); +DEC* *SubtractDecimalArrays( DEC *[], DEC *[], DEC *[], int ); +DEC* *SubtractDecimalFromDecimalArray( DEC *[], DEC *[], DEC *, int ); +DEC *SubtractDoubleFromDecimal( DEC *, DEC *, double ); +DEC *SubtractIntFromDecimal( DEC *, DEC *, int ); +DEC *SubtractLongFromDecimal( DEC *, DEC *, long ); +DEC *SubtractPercent( DEC *, DEC *, DEC * ); +DEC *SubtractUnsFromDecimal( DEC *, DEC *, unsigned int ); +DEC *SubtractUnsLongFromDecimal( DEC *, DEC *, unsigned long ); +DEC *SumDecimalArray( DEC *, DEC *[], int ); +DEC *SumDecimalArrayNegative( DEC *, DEC *[], int ); +DEC *SumDecimalArrayPositive( DEC *, DEC *[], int ); +DEC *SwapDecimal( DEC *, DEC * ); +DEC *TangentDecimal( DEC *, DEC *); +int TestSignDecimal( DEC * ); +DEC *TruncateCents( DEC *, DEC *, int ); +DEC *TruncateDecimal( DEC *, DEC *, int ); +DEC *UniformSeriesFutureValue( DEC *, DEC *, int ); +DEC *UniformSeriesPresentValue( DEC *, DEC *, int ); +DEC *WeightedMean( DEC *, DEC *[], DEC *[], int ); +DEC *ZeroDecimal( DEC * ); +DEC* *ZeroDecimalArray( DEC *[], int ); + +#ifdef __cplusplus +} +#endif + diff --git a/gfm/gmglobal.c b/gfm/gmglobal.c new file mode 100755 index 000000000..34076d4fa --- /dev/null +++ b/gfm/gmglobal.c @@ -0,0 +1,165 @@ +/* gmglobal.c + * + * ARGUMENT + * None. + * + * DESCRIPTION + * Global variable definitions for the math lib. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * AUTHOR + * Andy Anderson 13-JAN-1987 18:35 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * Don Killen - 10-19-1989 18:22:09 Added Imbedded Copyright Notice. + */ +#include +#include "gm.h" +#include "gmsystem.h" + +/* place for error return values */ +int wGMError=GM_SUCCESS; +/* function # that caused error */ +int wGMFunErrNum=0; + /* default error function handler */ + +void (*pfnGMErrVector)(int,int) = GMDefErrHandler; + +/* global storage for internal use */ +int _wGMUser=0; /* function called by user */ +int wGMTemp1=0; +int wGMTemp2=0; + +mbool wfGMRound=TRUE; /* next 30 used for formatted conversions */ +mbool wfFlagNumber=FALSE; +char cGMSymExp='e'; +int wGMStar=2; /* storage of * arguments for dtoaf */ +int wGMStar2=2; +char cGMFmt='t'; /* next 20 format string types */ +char cGMFmtComma='v'; +char cGMFmtSci='w'; +char cGMFmtSciE='W'; +char cGMFmtEng='z'; +char cGMFmtEngE='Z'; +char cGMFmtRnd='R'; +char cGMFmtTrunc='T'; +char cGMFmtDlr='$'; +char cGMFmtNegRgt1='m'; +char cGMFmtNegRgt2='M'; +char cGMFmtNegPar='a'; +char cGMFmtNegBrkt='A'; +char cGMFmtZeroBlC='q'; +char cGMFmtZeroBlS='Q'; +char cGMFmtZero=' '; +char *sGMFmtZeroStr="None"; +char cGMFmtSurrL='['; +char cGMFmtSurrR=']'; +char *sGMFmt1Pos =" (cr)"; +char *sGMFmt1Neg =" (dr)"; +char *sGMFmt1Zero=" "; +char *sGMFmt2Pos =" (dr)"; +char *sGMFmt2Neg =" (cr)"; +char *sGMFmt2Zero=" "; +mbool wfGM3Color=FALSE; /* next 4 used in 3-color printing */ +char cGMCodePos=0x24; +char cGMCodeNeg=0x25; +char cGMCodeNon=0x26; +int wIntrPrec=18; +/* next used to hold 160-bit partial products */ +int wrgGMPartProd[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +/* A Powers of ten table (25 entries in 80-bit format) */ +unsigned SHORT wrgGMPowersOfTen80Bit[]={0x0001,0x0000,0x0000,0x0000,0x0000, +0x000a,0x0000,0x0000,0x0000,0x0000, +0x0064,0x0000,0x0000,0x0000,0x0000, +0x03e8,0x0000,0x0000,0x0000,0x0000, +0x2710,0x0000,0x0000,0x0000,0x0000, +0x86a0,0x0001,0x0000,0x0000,0x0000, +0x4240,0x000f,0x0000,0x0000,0x0000, +0x9680,0x0098,0x0000,0x0000,0x0000, +0xe100,0x05f5,0x0000,0x0000,0x0000, +0xca00,0x3b9a,0x0000,0x0000,0x0000, +0xe400,0x540b,0x0002,0x0000,0x0000, +0xe800,0x4876,0x0017,0x0000,0x0000, +0x1000,0xd4a5,0x00e8,0x0000,0x0000, +0xa000,0x4e72,0x0918,0x0000,0x0000, +0x4000,0x107a,0x5af3,0x0000,0x0000, +0x8000,0xa4c6,0x8d7e,0x0003,0x0000, +0x0000,0x6fc1,0x86f2,0x0023,0x0000, +0x0000,0x5d8a,0x4578,0x0163,0x0000, +0x0000,0xa764,0xb6b3,0x0de0,0x0000, +0x0000,0x89e8,0x2304,0x8ac7,0x0000, +0x0000,0x6310,0x5e2d,0x6bc7,0x0005, +0x0000,0xdea0,0xadc5,0x35c9,0x0036, +0x0000,0xb240,0xc9ba,0x19e0,0x021e, +0x0000,0xf680,0xe14a,0x02c7,0x152d}; + +char _crn_[]={0x43,0x6f,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x43, + 0x29,0x31,0x39,0x38,0x37,0x2d,0x38,0x39,0x20,0x47,0x72,0x65,0x65,0x6e, + 0x6c,0x65,0x61,0x66,0x20,0x53,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,0x20, + 0x49,0x6e,0x63,0x2e,0x20,0x41,0x6c,0x6c,0x20,0x52,0x69,0x67,0x68,0x74, + 0x73,0x20,0x52,0x65,0x73,0x65,0x72,0x76,0x65,0x64,0x2e}; + +/* Powers of ten table in double format for internal use */ +double ergGMPowersOfTenDouble[25]={1.0,1e1,1e2,1e3,1e4,1e5,1e6,1e7, +1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20, +1e21,1e22,1e23,1e24}; + +double eTwoTo31= 2147483647.0; /* 2**31 */ +double eTwoTo32= 4294967296.0; /* 2**32 */ +double eTwoTo63= 9223372036854775808.0; /* 2**63 */ +double eTwoTo64=18446744073709551616.0; /* 2**64 */ + + /* 0.7 */ +DEC decPoint7={0,1,{0x0007,0,0,0},0}; + /* Decimal One */ +DEC decOne={0,0,{1,0,0,0},0}; + /* 1.4 */ +DEC decOnePoint4={0,1,{0x000e,0,0,0},0}; + /* 'e' */ +DEC decE={0,23,{0xa69c,0xb692,0x7ae9,0xd5d7,},0x398f}; +DEC decReciprocalOfLn2={0,23,{0xb7f8,0x4faf,0x9c42,0xdd90},0x1e8c}; +DEC decReciprocalOfLn10={0,23,{0x1839,0xcbbd,0xa605,0x50aa},0x0932}; +DEC decLn2={0,23,{0x4b1b,0xb4a3,0xfacf,0x8ef2},0x0ead}; +DEC decLn10={0,23,{0x1787,0xe426,0xa5f0,0x56bb},0x30c2}; +/* maximum exponent for e**x is e**43=4.7279394...E+18 */ +DEC decMaxExp={0,0,{43,0,0,0},0}; +/* minimum exponent for e**x is e**-42=1.5628821...E-18 */ +DEC decMinExp={1,0,{42,0,0,0},0}; +/* constants used in square root */ +DEC decPoint819={0,3,{819,0,0,0},0}; +DEC decPoint259={0,3,{259,0,0,0},0}; +DEC decTwoPoint59={0,2,{259,0,0,0},0}; +DEC decPoint0819={0,4,{819,0,0,0},0}; +DEC decPoint5={0,1,{5,0,0,0},0}; +/* constants used in trig */ +DEC decPi={0,23,{0xde78,0xfbea,0x5cdd,0x9b9f},0x4286}; +DEC decPiOver2={0,23,{0x6f3c,0xfdf5,0xae6e,0x4dcf},0x2143}; +DEC decPiOver4={0,23,{0xb79e,0x7efa,0xd737,0xa6e7},0x10a1}; +DEC dec2Pi={0,22,{0x92e5,0x98c8,0xdf5f,0x1f1f},0x0d4e}; +DEC decPiOver6={0,23,{0xcfbf,0xff51,0x3a24,0x6f45},0x0b16}; +DEC decReciprocalOfSqrt3={0,23,{0x6563,0x8bd3,0xe183,0xd273},0x0c39}; +DEC dec180OverPi={0,22,{0x91ee,0x89a6,0x22fb,0x1ab4},0x7954}; +DEC decPiOver180={0,23,{0x75dc,0xc43e,0x1b89,0x9d4f},0x005e}; +/* statistical globals for linear estimation */ +DEC decMaxLinEst={0,0,{0x4240,0x000f,0,0},0}; +DEC decMinLinEst={1,0,{0x4240,0x000f,0,0},0}; +DEC decMaxTime={0,0,{1000,0,0,0},0}; +DEC decMinusHundred={1,0,{100,0,0,0},0}; +DEC decHundred={0,0,{100,0,0,0},0}; +DEC decMinus50={1,0,{50,0,0,0},0}; +DEC decOnePoint6={0,1,{16,0,0,0},0}; +DEC decGMIRRGuess={0,0,{2,0,0,0},0}; +DEC *pGMIRRGuess=&decGMIRRGuess; +DEC decPoint01={0,2,{1,0,0,0},0}; +DEC decStatA={0,0,{0,0,0,0},0}; +DEC decStatB={0,0,{1,0,0,0},0}; +DEC *pGMStatA = &decStatA; +DEC *pGMStatB = &decStatB; diff --git a/gfm/gmrs.c b/gfm/gmrs.c new file mode 100755 index 000000000..05065b21d --- /dev/null +++ b/gfm/gmrs.c @@ -0,0 +1,34 @@ +/* void ClearMathError() + * + * ARGUMENT + * None. + * + * DESCRIPTION + * Clears wGMError to the value GM_SUCCESS. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * POSSIBLE ERRORS + * None. + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gmsystem.h" +void ClearMathError() +{ + wGMError=GM_SUCCESS; + wGMFunErrNum=0; +} + diff --git a/gfm/gmserri.c b/gfm/gmserri.c new file mode 100755 index 000000000..d9b6889d9 --- /dev/null +++ b/gfm/gmserri.c @@ -0,0 +1,41 @@ +/* void GMDefErrHandler(a,b) + * + * ARGUMENT + * int a,b; a= value for wGMError + * b= value for wGMFunErrNum + * + * DESCRIPTION + * Sets global var's wGMError to 'a' and wGMFunErrNum to 'b' + * IF AND ONLY IF wGMError is equal to GM_SUCCESS or wGMError is a warning + * and 'a' is a fatal error. If not, neither global variable is changed. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * None. + * + * AUTHOR + * AA 17-Sep-87 0900 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +void GMDefErrHandler(wErrorNo, wErrorFunctionNum) +int wErrorNo, wErrorFunctionNum; +{ + + if((wGMError == GM_SUCCESS) || + ((wGMError == GM_CNVRW) && (wErrorNo != GM_CNVRW))) { + wGMError = wErrorNo; + wGMFunErrNum = wErrorFunctionNum; + } + return; +} diff --git a/gfm/gmsys1.h b/gfm/gmsys1.h new file mode 100755 index 000000000..2d4b3fe29 --- /dev/null +++ b/gfm/gmsys1.h @@ -0,0 +1,7 @@ +#define BITSPERUI 16 +#ifdef M_I386 +#define SHORT short +#else +#define SHORT int +#endif + diff --git a/gfm/gmsystem.h b/gfm/gmsystem.h new file mode 100755 index 000000000..c50f80b02 --- /dev/null +++ b/gfm/gmsystem.h @@ -0,0 +1,147 @@ +/* Include this only when compiling MathLib source code. +* +* Greenleaf Financial Mathlib +* +* Contains definitions and prototypes used by internal routines. +* Copyright (C)1987-1990 Greenleaf Software Inc. All rights reserved. +*/ +#ifndef _MSC +#define _MSC +#endif +#ifndef GMDOTH +#include +#endif + +#define GM_IMAXID 23 /* values for intermediate calcs. */ +#define GM_IMINID 0 + +/* then define the global constants that are in gmglobal.c */ +extern int _wGMUser; +extern unsigned SHORT wrgGMPowersOfTen80Bit[]; +extern double ergGMPowersOfTenDouble[]; +extern double eTwoTo31; +extern double eTwoTo32; +extern double eTwoTo63; +extern double eTwoTo64; +extern DEC decPoint7; +extern DEC decOne; +extern DEC decOnePoint4; +extern DEC decReciprocalOfLn2; +extern DEC decReciprocalOfLn10; +extern DEC decLn2; +extern DEC decLn10; +extern DEC decE; /* Naperian base(2.71828...) */ +extern DEC decMaxExp; /* max exponent for e**x in DEC */ +extern DEC decMinExp; /* min exponent for e**x in DEC */ +extern DEC decPoint259; /* next 5 used for square root */ +extern DEC decTwoPoint59; /* 2.59 */ +extern DEC decPoint819; /* 0.819 */ +extern DEC decPoint0819; /* 0.0819 */ +extern DEC decPoint5; /* 0.5 */ +extern DEC decPi; /* next 6 used for trig */ +extern DEC decPiOver2; +extern DEC decPiOver4; +extern DEC decPiOver6; +extern DEC dec2Pi; +extern DEC decReciprocalOfSqrt3; +extern DEC dec180OverPi; +extern DEC decPiOver180; +extern DEC decMaxLinEst; /* next 2 used in linear estimation */ +extern DEC decMinLinEst; +extern DEC decMaxTime; /* maximum time for business */ +extern DEC decMinusHundred; +extern DEC decHundred; +extern DEC decMinus50; +extern DEC decOnePoint6; +extern DEC decPoint01; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef M_I386 +#define SHORT short +#else +#define SHORT int +#endif + +int _AddDec80Bit( DEC *, DEC *, DEC *); +int GF_CDECL _AddUnsArrToUnsArr( unsigned SHORT [], unsigned SHORT [], + unsigned SHORT [], int ); +void _ATanDec80Bit( DEC *, DEC *); +int GF_CDECL _CompareUnsArr( unsigned SHORT [], unsigned SHORT [], int ); +DEC * _CompoundAux( int , int *, DEC *, DEC *, DEC *, DEC *, + DEC *, int , int ); +void _ConvDecimalToAsciiFormatted( char *, DEC *, char *); +void _CosDec80Bit( DEC *, DEC *); +void _CosDecSmall( DEC *, DEC *); +int _DivDec80Bit( DEC *, DEC *, DEC *); +int _DivDecFast( DEC *, DEC *, DEC *); +int _DivProcFast( DEC *, DEC *, DEC *); +int _DivProcRnd( DEC *, unsigned SHORT [], unsigned SHORT [], int , + int , int ); +int _DivProcTrn( DEC *, unsigned SHORT [], unsigned SHORT [], int , + int , int ); +int _DivRndDec80Bit( DEC *, DEC *, DEC *, int ); +int _DivTrnDec80Bit( DEC *, DEC *, DEC *, int ); +void _DivUns10ArrByUns5Arr( unsigned SHORT [], unsigned SHORT [], + unsigned SHORT [] ); +void _DivUns10ArrByUns5ArrTrn( unsigned SHORT [], unsigned SHORT [], + unsigned SHORT [] ); +void GF_CDECL _DivUnsArrByPwrOf10( unsigned SHORT [], int , int ); +void GF_CDECL _DivUnsArrByPwrOf10Trunc( unsigned SHORT [], int , int ); +unsigned GF_CDECL _DivUnsArrByUns( unsigned SHORT [], unsigned SHORT , int ); +void GF_CDECL _DivUnsArrByUnsArr( unsigned SHORT [], unsigned SHORT [], int , + unsigned SHORT [], int , int ); +void GF_CDECL _DivUnsArrByUnsRound( unsigned SHORT [], unsigned SHORT , int ); +void GF_CDECL _DoubleUnsArr( unsigned SHORT [], int ); +int _ExpDec80Bit( DEC *, DEC *); +void GF_CDECL _HalveUnsArr( unsigned SHORT [], int ); +void GF_CDECL _IncrementUnsArr( unsigned SHORT [] ); +int _IntPwrDec80Bit( DEC *, DEC *, int ); +DEC * _InterestAux( int , int , DEC * , DEC * , DEC *, DEC *, DEC *, + int ); +int _LnDec80Bit( DEC *, DEC *); +int _MulDec80Bit( DEC *, DEC *, DEC *); +void GF_CDECL _MulUnsArr( unsigned SHORT [], unsigned SHORT [], unsigned SHORT, int); +int GF_CDECL _MulUnsArrByPwrOf10( unsigned SHORT [], int , int ); +int GF_CDECL _MulUnsArrByPwrOf10Limited( unsigned SHORT [], int , int ); +void GF_CDECL _MulUnsArrByUnsArr( unsigned SHORT [], unsigned SHORT [], + unsigned SHORT [], int , int , int ); +int GF_CDECL _MulUnsArrP10AndAddInt( unsigned SHORT [], int ); +int _ScaleDec80Bit( DEC *, DEC *, int ); +int _ScanfAux( int , char *, char *, ELLIPSES); +DEC * _SimpleAux( int *, DEC *, DEC *, DEC *, int , int ); +void _SinDecSmall( DEC *, DEC *); +int _SortDec( DEC **, DEC **); +int _SortInc( DEC **, DEC **); +int _Sq5UnsTo4Uns( DEC *); +void _SqrtDec80Bit( DEC *, DEC *); +int _SubDec80Bit(DEC *, DEC *, DEC *); +void GF_CDECL _SubUnsArr( unsigned SHORT [], unsigned SHORT [], int ); +int GF_CDECL _SubUnsArrFromUnsArr( unsigned SHORT [], unsigned SHORT [], unsigned SHORT [], + int ); +int _TruncateDec80Bit( DEC *, DEC *, int ); + +#ifdef __cplusplus +} +#endif + +/*****/ + +#define _MacDZero(a) { (a)->dc.attr=0; (a)->dc.id=2; (a)->dc.sl[0]=0; (a)->dc.sl[1]=0; (a)->dc.sl[2]=0; (a)->dc.sl[3]=0; (a)->dc.msd=0; } +#define _MacIsDecZ(a) ((((a)->ls.lsl[0])|((a)->ls.lsl[1])|((a)->dc.msd)) ? FALSE:TRUE) +#define _MacIsDecP(a) (((((a)->dc.attr&GM_NEG)^GM_NEG)&&(!_MacIsDecZ(a))) ? TRUE : FALSE) +#define _MacIsDecN(a) (((a)->dc.attr&GM_NEG)&&(!_MacIsDecZ(a))) +#define _MacDCopy(a,b) ((*a) = (*b)) +#define _MacDChgs(a) a->dc.attr=a->dc.attr^GM_NEG; +#define _MacStart(a) int _wGMCurr=(a); if (!_wGMUser) _wGMUser=(a); +#define _MacRet(a) {if (_wGMUser==_wGMCurr) _wGMUser=0; return(a);} +#define _MacRetV {if (_wGMUser==_wGMCurr) _wGMUser=0; return;} +#define _MacErr(a) SetMathError((a),_wGMUser) +#define _MacBad(a) (a->dc.iddc.id>GM_IMAXID+5) +#define _MacInVar(a,b) {if (!a) {_MacErr(GM_NULLPOINTER); _MacRet(b);} else if (_MacBad(a)) {_MacErr(GM_INIT); _MacRet(b);}} +#define _MacOutVar(a,b) {if (!a) {_MacErr(GM_NULLPOINTER); _MacRet(b);}} +#define _MacInVarD(a) {if (!a) {_MacErr(GM_NULLPOINTER); _MacRet(GM_NULL);} else if (_MacBad(a)) {_MacErr(GM_INIT); _MacRet(GM_NULL);}} +#define _MacOutVarD(a) {if (!a) {_MacErr(GM_NULLPOINTER); _MacRet(GM_NULL);}} +#define _MacInVarI(a) {if (!a) {_MacErr(GM_NULLPOINTER); _MacRet(GM_NULLPOINTER);} else if (_MacBad(a)) {_MacErr(GM_INIT); _MacRet(GM_INIT);}} diff --git a/gfm/hmi.asm b/gfm/hmi.asm new file mode 100755 index 000000000..3b26bd80a --- /dev/null +++ b/gfm/hmi.asm @@ -0,0 +1,70 @@ + ; void _HalveUnsArr(a,n) + ; + ; ARGUMENT + ; unsigned *a[]; + ; unsigned n; + ; + ; DESCRIPTION + ; Halves the number a (taken as one number of 'n' 16-bit unsigneds). + ; + ; SIDE EFFECTS + ; If number is odd, discards low-order bit. + ; + ; RETURNS + ; None. + ; + ; AUTHOR + ; Andy Anderson 31-JAN-1987 13:30 + ; Copyright (C) 1987-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; aa 08-JUL-87 80-bit + ; + ; + + include model.h + include prologue.h + include gm.equ + + pseg gmath +; +; if large memory model then: +; +; parm1_ = ptr to source 1 +; parm3_ = number of words to shift right (divide by 2) +; +; for if small model then +; parm1_ = ptr to source1 +; parm2_ = number of words to shift right (divide by 2) +; +; + + cproc _HalveUnsArr,,_hmi + +if _LDATA + push ds + lds si,parm1_ ; ptr to a + mov cx,parm3_ ; get number of words to shift +else + mov si,parm1_ + mov cx,parm2_ ; ditto for small model +endif + xor bx,bx ; clear flags + mov bx,cx ; then convert number of word to + dec bx ; index for loop + rcl bx,1 ; change byte to word offset + xor ax,ax ; clear flags +lp: + rcr Word Ptr [bx+si],1 ; word and divide it by 2 + dec bx ; and decrease the index (offset) + dec bx + loop lp ; for next until done + +; no return values +if _LDATA + pop ds +endif + cproce + endps + END + diff --git a/gfm/hmi.c b/gfm/hmi.c new file mode 100755 index 000000000..b54f85122 --- /dev/null +++ b/gfm/hmi.c @@ -0,0 +1,50 @@ +/* unsigned _HalveUnsArr(a,n) + * + * ARGUMENT + * unsigned a[]; + * int n; number of digits + * + * DESCRIPTION + * Halves (Divides by 2) the number a. + * + * SIDE EFFECTS + * If the number is odd, discards the least significant bit. + * + * RETURNS + * + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +#include "gmsys1.h" + +void _HalveUnsArr(a,n) +unsigned SHORT a[]; +int n; +{ + int i; + unsigned SHORT rem,qt; + unsigned long remup,ntbd; + + rem=0; + + if (n) + { + for (i=n-1;i>=0;i--) + { + remup=(long)rem< +#include "gm.h" +#include "gmsystem.h" +static void zcom(DEC *, int, int, DEC *, DEC *, DEC *, DEC *, DEC *, int); + +DEC *_InterestAux(fun, intper, fractper, intr, pv, pmt, fv, begend) +int fun, intper, begend; +DEC *fractper, *intr, *pv, *pmt, *fv; +{ + int i, places, ad; + mbool wfDone; + DEC dx1, *x1=&dx1, dx2, *x2=&dx2, dpx1, *px1=&dpx1; + DEC dpx2, *px2=&dpx2, dy1, *y1=&dy1, dy2, *y2=&dy2; + DEC dy0, *y0=&dy0, dxn, *xn=&dxn, dyn, *yn=&dyn; + DEC djunk, *junk=&djunk; + DEC dtemp1, *temp1=&dtemp1, dtemp2, *temp2=&dtemp2; + +/* Can't have zero payments */ + if (intper==0) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + ad = begend; + +/* add advance payments to pv */ + if (fun==0) { + (void) ConvLongToDecimal(junk, (long) ad); + (void) _MulDec80Bit(junk, pmt, junk); + (void) _AddDec80Bit(junk, junk, pv); + pv = junk; + } + +/* Check that there's a positive & a negative value among pv, pmt, fv */ + if (!(_MacIsDecP(pv)||_MacIsDecP(pmt)||_MacIsDecP(fv))) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + if (!(_MacIsDecN(pv)||_MacIsDecN(pmt)||_MacIsDecN(fv))) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + +/* if pmt==0, solve quickly */ +/* 0 = pv + fv * (1 + i/100) ^ n ==> + i = (exp[ ln (fv / pv) / n] - 1) * 100 */ + if (_MacIsDecZ(pmt)&&fun<=1) { + (void) _DivDec80Bit(temp1, fv, pv); + _MacDChgs(temp1); + (void) _LnDec80Bit(temp1, temp1); + (void) ConvLongToDecimal(temp2, (long) intper); + (void) _DivDec80Bit(temp1, temp1, temp2); + (void) _ExpDec80Bit(temp1, temp1); + (void) _SubDec80Bit(temp1, temp1, &decOne); + temp1->dc.id-=2; + (void) _ScaleDec80Bit(intr, temp1, wIntrPrec); + (void) _Sq5UnsTo4Uns(intr); + return(intr); + } + +/* find bounds for intr */ +/* initial bounds: 0 and 1 (percent) */ + _MacDZero(x1); + _MacDCopy(x2, (&decOne)); + zcom(y1, fun, intper, fractper, x1, pv, pmt, fv, begend); + zcom(y2, fun, intper, fractper, x2, pv, pmt, fv, begend); + if (_MacIsDecZ(y1)) { + _MacDCopy(intr,y1); + return(intr); + } + if (_MacIsDecZ(y2)) { + _MacDCopy(intr,y2); + return(intr); + } + _MacDCopy(y0,y1); + _MacDCopy(px1, x2); + _MacDCopy(px2, x1); + +/* expanded bounds until zcom has different signs at bounds to find zero */ + i=0; + while (!_MacIsDecN(y1)^_MacIsDecN(y2)) { +/* change boundary with smaller absolute value */ + if ((CompareDecimal(x1,x2)==1)^_MacIsDecN(y1)) { +/* set x2 = 2 * x2 */ + _MacDCopy(px2,x2); + _AddDec80Bit(x2,x2,x2); + zcom(y2, fun, intper, fractper,x2,pv,pmt, fv, begend); + if (_MacIsDecZ(y2)) { + _MacDCopy(intr,x2); + return(intr); + } + } + + else { +/* if x1==0, set x1 = 10%, otherwise x1 = (old x1 + -100%) / 2 */ + _MacDCopy(px1,x1); + if (_MacIsDecZ(x1)) + (void) ConvLongToDecimal(x1, 10L); + else { + (void) _AddDec80Bit(x1,x1,&decMinusHundred); + (void) _MulDec80Bit(x1,x1,&decPoint5); + } + zcom(y1, fun, intper, fractper,x1,pv,pmt, fv, begend); + if (_MacIsDecZ(y1)) { + _MacDCopy(intr,x1); + return(intr); + } + } + +/* maximum of 19 expansions */ + i++; + if (i>19) { + _MacErr(GM_ARGVAL); + return(GM_NULL); + } + + } + + places=wIntrPrec; + if (placesGM_MAXID) + places=GM_MAXID; + + (void) _ScaleDec80Bit(x1,x1,places); + (void) _ScaleDec80Bit(x2,x2,places); + + if (CompareDecimal(x1,&decMinusHundred)==0) { + _MacDCopy(intr,x2); + return(intr); + } + +/* Restrict range to smaller region with different signs */ + if (_MacIsDecN(y0)^_MacIsDecN(y2)) + _MacDCopy(x1,px2); + else + _MacDCopy(x2,px1); + + +/* Find root by bisection (Numerical Recipes in C, p. 263) */ + wfDone=FALSE; + while (!wfDone) { +/* calculate new position */ + (void) _AddDec80Bit(xn, x2, x1); + _HalveUnsArr(xn->dc.sl, 5); +/* (void) _SubDec80Bit(temp1, x2, x1); + (void) _SubDec80Bit(temp2, y2, y1); + (void) _DivDec80Bit(temp1, temp1, temp2); + (void) _MulDec80Bit(temp1, temp1, y1); + (void) _SubDec80Bit(xn, x1, temp1); */ + +/* calculate corresponding y */ + zcom(yn, fun, intper, fractper, xn, pv, pmt, fv, begend); + +/* check for approximate or exact zero */ + if (_MacIsDecZ(yn)) { + _MacDCopy(intr,xn); + return(intr); + } + +/* adjust appropriate boundary */ + if (_MacIsDecN(y1)^_MacIsDecN(yn)) { + wfDone=(CompareDecimal(x2,xn)==0); + _MacDCopy(x2,xn); + _MacDCopy(y2,yn); + } + else { + wfDone=(CompareDecimal(x1,xn)==0); + _MacDCopy(x1,xn); + _MacDCopy(y1,yn); + } + + } + + (void) _Sq5UnsTo4Uns(xn); + _MacDCopy(intr,xn); + return(intr); +} + + +/* calculate function which must be zeroed to solved for intr */ +static void zcom(y, fun, intper, fractper, intr, pv, pmt, fv, begend) +int fun, intper, begend; +DEC *y, *fractper, *intr, *pv, *pmt, *fv; +{ + int ad; + DEC dopi, *opi=&dopi, dopitmn, *opitmn=&dopitmn; + DEC dtemp2, *temp2=&dtemp2, dopitmna, *opitmna=&dopitmna; + DEC dnintr, *nintr=&dnintr; + + ad=begend; + + _MacDCopy(nintr, intr); + if (intr->dc.id<=GM_IMAXID-2) + nintr->dc.id+=2; + else + (void) _MulDec80Bit(nintr,intr,&decPoint01); + + (void) _AddDec80Bit(opi, &decOne, nintr); + (void) _IntPwrDec80Bit(opitmn, opi, -intper); + if (fun==0) + (void) _IntPwrDec80Bit(opitmna, opi, -(intper-ad)); + + (void) _MulDec80Bit(y, fv, opitmn); + + if (!_MacIsDecZ(pv)) { + if (fun<=1) + _MacDCopy(temp2, pv); + if (fun==2) { + (void) _MulDec80Bit(temp2, nintr, fractper); + (void) _AddDec80Bit(temp2, temp2, &decOne); + (void) _MulDec80Bit(temp2, temp2, pv); + } + if (fun==3) { + (void) PowerDecimal(temp2, opi, fractper); + (void) _MulDec80Bit(temp2, temp2, pv); + } + (void) _AddDec80Bit(y, y, temp2); + } + + if (_MacIsDecZ(nintr)) { + if (fun!=0) + (void) ConvLongToDecimal(temp2, (long) intper); + else + (void) ConvLongToDecimal(temp2, (long) (intper-ad)); + (void) _MulDec80Bit(temp2, temp2, pmt); + } + else { + if (fun!=0) + (void) _SubDec80Bit(temp2, &decOne, opitmn); + else + (void) _SubDec80Bit(temp2, &decOne, opitmna); + (void) _DivDec80Bit(temp2, temp2, nintr); + (void) _MulDec80Bit(temp2, temp2, pmt); + if (begend==GM_BEGIN&&fun!=0) + (void) _MulDec80Bit(temp2, temp2, opi); + } + (void) _AddDec80Bit(y, y, temp2); + + +} diff --git a/gfm/irr.c b/gfm/irr.c new file mode 100755 index 000000000..6e990111e --- /dev/null +++ b/gfm/irr.c @@ -0,0 +1,224 @@ +/* DEC *InternalRateOfReturn(irr, flows, nflow) + * + * ARGUMENT + * DEC *irr, **flows; + * int nflow; + * + * DESCRIPTION + * Calculates the internal rate of return of a series of cash flows. + * The internal rate of return, rounded to wGMIntrPrec decimal places, + * is stored in irr. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * irr if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gmsystem.h" +static void _NPVaux(DEC *, DEC **, int, DEC *); + +DEC *InternalRateOfReturn(irr, flows, nflow) +DEC *irr, **flows; +int nflow; +{ + mbool wfPos, wfNeg, wfDone; + int i, j, places; + DEC dx1, *x1=&dx1, dx2, *x2=&dx2; + DEC dy1, *y1=&dy1, dy2, *y2=&dy2; + DEC dxn, *xn=&dxn, dyn, *yn=&dyn; + DEC dtemp, *temp=&dtemp, dtemp2, *temp2=&dtemp2; + + _MacStart(GM_IRR); + + if (nflow<2) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + if (!flows||!irr) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + + /* check for null pointers, at least one pos & neg cash flow */ + wfPos=FALSE; + wfNeg=FALSE; + for (i=0;i18) + places=18; + +/* find bounds */ +/* + * The initial 2 guesses for IRR have been changed. The old code started + * with guesses of 2% & 2.2%, and tried to extrapolate from there. I + * have changed it to guess 2% and -2%. + */ + /* load initial guesses */ + _MacDCopy(x1, pGMIRRGuess); + if (_MacIsDecZ(x1)) + (void) MakeDecimalFromLong(x2, 1L, 1); + _MacDCopy( x2, x1 ); + _MacDChgs( x2 ); + + _NPVaux(y1, flows, nflow, x1); + _NPVaux(y2, flows, nflow, x2); + + /* use secant method to find bounds */ + i=0; + while ((!(_MacIsDecN(y1)^_MacIsDecN(y2))) && i<15) { + i++; + j = CompareDecimal(y1, y2); + if (j==0) { /* |y1|=|y2| */ + (void) _AddDec80Bit(x2, x1, x2); + (void) _MulDec80Bit(x2, x2, &decPoint5); + _NPVaux(y2, flows, nflow, x2); + } + else { + /* compute new value */ + (void) _SubDec80Bit(temp, x2, x1); + (void) _SubDec80Bit(temp2, y2, y1); + (void) _DivDec80Bit(temp, temp, temp2); + (void) _MulDec80Bit(temp, temp, &decOnePoint6); + if ((j==1)^(_MacIsDecN(y1))) { /* |y1|>|y2| */ + (void) _MulDec80Bit(temp, temp, y2); + (void) _SubDec80Bit(x1, x2, temp); + _NPVaux(y1, flows, nflow, x1); + } + else { /* |y2|>|y1| */ + (void) _MulDec80Bit(temp, temp, y1); + (void) _SubDec80Bit(x2, x1, temp); + _NPVaux(y2, flows, nflow, x2); + } + } + } + + /* find bounds, method 2 */ + if (i>=15) { + /* load initial guesses */ + _MacDCopy(x1, pGMIRRGuess); + if (_MacIsDecZ(x1)) + MakeDecimalFromLong(x2, 1L, 1); + else { + _MacDCopy(x2, x1); + x2->dc.id++; + (void) _SubDec80Bit(x2, x1, x2); + } + _NPVaux(y1, flows, nflow, x1); + _NPVaux(y2, flows, nflow, x2); + + while (!(_MacIsDecN(y1)^_MacIsDecN(y2))) { + j = CompareDecimal(y1, y2); + if ((j==1)^(_MacIsDecN(y1))) { /* |y1|>|y2| */ + _AddDec80Bit(temp, x2, x2); + _SubDec80Bit(x2, temp, x1); + if ((CompareDecimal(x2, &decHundred) == 1) + || (CompareDecimal(x2, &decMinus50) == -1)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + _NPVaux(y2, flows, nflow, x2); + } + else { /* |y2|>|y1| */ + _AddDec80Bit(temp, x1, x1); + _SubDec80Bit(x1, temp, x2); + if ((CompareDecimal(x1, &decHundred) == 1) + || (CompareDecimal(x1, &decMinus50) == -1)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + _NPVaux(y1, flows, nflow, x1); + } + } + } + + +/* If this stage is reached, bounds have been found */ +/* Now use bisection to find the IRR between those bounds */ + wfDone=FALSE; + while (!wfDone) { +/* calculate new position */ + (void) _AddDec80Bit(xn, x2, x1); + _HalveUnsArr(xn->dc.sl, 5); + if (xn->dc.id != places) + _ScaleDec80Bit(xn, xn, places); + +/* calculate corresponding y */ + _NPVaux(yn, flows, nflow, xn); + +/* check for approximate or exact zero */ + if (_MacIsDecZ(yn)) { + _MacDCopy(irr,xn); + _MacRet(irr); + } + +/* adjust appropriate boundary */ + if (_MacIsDecN(y1)^_MacIsDecN(yn)) { + wfDone=(CompareDecimal(x2,xn)==0); + _MacDCopy(x2,xn); + _MacDCopy(y2,yn); + } + else { + wfDone=(CompareDecimal(x1,xn)==0); + _MacDCopy(x1,xn); + _MacDCopy(y1,yn); + } + + } + + _MacDCopy(irr, xn); + _MacRet(xn); +} + +static void _NPVaux(net, flows, nflow, intr) +DEC *net, **flows, *intr; +int nflow; +{ + int i; + DEC dtemp, *temp=&dtemp, dooopi, *ooopi=&dooopi; + DEC dpow, *pow=&dpow; + + _MacDZero(net); + _MacDCopy(temp, intr); + if (temp->dc.id <= GM_MAXID-2) + temp->dc.id+=2; + else + (void) _DivUnsArrByPwrOf10(temp->dc.sl, 5, 2); + (void) _AddDec80Bit(temp, temp, &decOne); + (void) _DivDec80Bit(ooopi, &decOne, temp); + + _MacDCopy(pow, (&decOne)); + + for (i=0;i +#include "gm.h" +#include "gmsystem.h" + +DEC *ConvIntToDecimal( x, l) +DEC *x; +int l; + +{ + DEC *t; + _MacStart(GM_ITOD); + + t=(ConvLongToDecimal(x, (long) l)); + _MacRet(t); +} diff --git a/gfm/libgfm.sl b/gfm/libgfm.sl new file mode 100755 index 000000000..da9299070 --- /dev/null +++ b/gfm/libgfm.sl @@ -0,0 +1,124 @@ +## +## Specification file per costruire la shared library di gfm. +## Nella branch table vengono messi solo le funzioni direttamente +## interfacciabili con l'utente. Le funzioni che iniziano con _ +## non vengono rese pubbliche. +## +#address .text 0xB0000000 +#address .data 0xB0400000 +#target /shlib/libgfm_s +#branch + GMDefErrHandler 1 + _ScanfAux 2 +## _AddUnsArrToUnsArr 2 +## _CompoundAux 3 +## _AddDec80Bit 4 +## _ATanDec80Bit 5 +## _ScaleDec80Bit 6 +## _CosDecSmall 7 +## _CosDec80Bit 8 +## _DivProcFast 9 +## _DivProcRnd 10 +## _DivProcTrn 11 +## _DivDec80Bit 12 +## _DivDecFast 13 +## _DivRndDec80Bit 14 +## _DivTrnDec80Bit 15 +## _ExpDec80Bit 16 +## _LnDec80Bit 17 +## _DivUnsArrByUnsArr 18 +## _DivUnsArrByPwrOf10 19 +## _DivUnsArrByPwrOf10Trunc 20 +## _DivUnsArrByUns 21 +## _DivUnsArrByUnsRound 22 +## _IntPwrDec80Bit 23 +## _SinDecSmall 24 +## _SqrtDec80Bit 25 +## _SubDec80Bit 26 +## _ConvDecimalToAsciiFormatted 27 +## _TruncateDec80Bit 28 +## _DivUns10ArrByUns5Arr 29 +## _DivUns10ArrByUns5ArrTrn 30 +## _CompareUnsArr 31 +## _IncrementUnsArr 32 +## _HalveUnsArr 33 +## _InterestAux 34 +## _MulUnsArrByUnsArr 35 +## _MulUnsArr 36 +## _MulUnsArrByPwrOf10 37 +## _MulUnsArrByPwrOf10Limited 38 +## _MulUnsArrP10AndAddInt 39 +## _ScanfAux 40 +## _SubUnsArrFromUnsArr 41 +## _SimpleAux 42 +## _SubUnsArr 43 +## _Sq5UnsTo4Uns 44 +## _SortInc 45 +## _SortDec 46 +## _DoubleUnsArr 47 +## _MulDec80Bit 48 +## Multiply 48 +## Mltply 49 + +#objects + gfmdefs.o + gmglobal.o + gmserri.o + agmn.o + mgmn.o + dmi.o + mli.o + smi.o + mul10.o + mul10ad.o + sgmn.o + gcmp.o + hmi.o + ginc.o + dmbyn.o + d10by5t.o + d10by5.o + dmby1r.o + dmby1.o + dmbyp10.o + dmbyp10t.o + dchix.o + sq5to4.o + ddivpf.o + ddivpr.o + ddivpt.o + ddix.o + ddixf.o + ddixr.o + ddixt.o + atod.o + atodr.o + scanfx.o +## compaux.o +## dadx.o +## datax.o +## dcoss.o +## dcox.o +## dcmp.o +## dsign.o +## dmby1r.o +## dpoxi.o +## dlnx.o +## dmag.o +## dtrux.o +## dsux.o +## dsins.o +## dmux.o +## intraux.o +## dexx.o +## mul10l.o +## dtoi.o +## ltod.o + +#objects noload + -lc_s + +#init gfmdefs.o + _libgfm_scanf scanf + _libgfm_fscanf fscanf + _libgfm_sscanf sscanf diff --git a/gfm/linest.c b/gfm/linest.c new file mode 100755 index 000000000..4e69c8b2a --- /dev/null +++ b/gfm/linest.c @@ -0,0 +1,145 @@ +/* DEC *LinearEstimate(pCorr, pLinA, pLinB, pSrcX, pSrcY, wSize); + * + * ARGUMENT + * DEC *pCorr, *pLinA, *pLinB; + * DEC **pSrcX, **pSrcY; + * int wSize; + * + * DESCRIPTION + * Determines the least squares line y = A + B * x and the + * linear correlation coefficient of a given set of (X, Y) values. + * The wSize (X, Y) values, where wSize > 1, are stored in arrays + * pSrcX and pSrcY. The correlation coefficient is put in pCorr. + * The value A is put in the global pGMStatA, along with pLinA, + * while B is put in the global pGMStatB and pLinB. Storing A and + * B in globals allow their later usage in PredictX and PredictY. + * The correlation coefficient is returned. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to the correlation coefficient if successful, + * otherwise returns GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_ARGVAL + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *LinearEstimate(pCorr, pLinA, pLinB, pSrcX, pSrcY, wSize) +DEC *pCorr, *pLinA, *pLinB; +DEC **pSrcX, **pSrcY; +int wSize; +{ + int i; + DEC dSumX, *pSumX=&dSumX, dSumY, *pSumY=&dSumY; + DEC dSumXX, *pSumXX=&dSumXX, dSumYY, *pSumYY=&dSumYY; + DEC dSumXY, *pSumXY=&dSumXY, dSize, *pSize=&dSize; + DEC dProd, *pProd=&dProd, dProd2, *pProd2=&dProd2; + DEC dVarX, *pVarX=&dVarX, dVarY, *pVarY=&dVarY; + DEC dNum, *pNum=&dNum, dDen, *pDen=&dDen; + _MacStart(GM_LINEST); + + if (!pSrcX||!pSrcY||!pCorr||!pLinA||!pLinB) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + + if (wSize<=1) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + for (i=0; i +#include "gm.h" +#include "gmsystem.h" + +int LookUpDecimalArray(pSrc,match,wCrit,size) +DEC *pSrc[]; +int size; +DEC *match; +int wCrit; +{ + int i,wRetVal; + + _MacStart(GM_LOOKARR); + /* make sure a comparison can be made */ + _MacInVarI(match); + if(!pSrc) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLPOINTER); + } + + if (size<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_ARGVAL); + } + + if (!(wCrit==GM_DEQ||wCrit==GM_DGT||wCrit==GM_DGEQ + ||wCrit==GM_DLEQ||wCrit==GM_DLT||wCrit==GM_DNE)) { + _MacErr(GM_ARGVAL); + _MacRet(GM_ARGVAL); + } + + for (i=0;i=0) + {_MacRet(i);} + else + break; + } + case GM_DLEQ: { + if(wRetVal<=0) + {_MacRet(i);} + else + break; + } + case GM_DLT: { + if(wRetVal<0) + {_MacRet(i);} + else + break; + } + case GM_DGT: { + if(wRetVal>0) + {_MacRet(i);} + else + break; + } + case GM_DNE: { + if(wRetVal!=0) + {_MacRet(i);} + else + break; + } + } + i++; + } + + /* no match by now means none meet criteria */ + _MacErr(GM_NOTFOUND); + _MacRet(GM_NOTFOUND); + +} diff --git a/gfm/ltod.c b/gfm/ltod.c new file mode 100755 index 000000000..6ad25a256 --- /dev/null +++ b/gfm/ltod.c @@ -0,0 +1,47 @@ +/* DEC *ConvLongToDecimal( x, l) + * + * ARGUMENT + * DEC *x; + * long l; + * + * DESCRIPTION + * Converts long 'l' to a DEC with implied decimal 0. + * + * SIDE EFFECTS + * x is indeterminate on error. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_NOMEMORY + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ConvLongToDecimal( x, l) +DEC *x; +long l; + +{ + _MacStart(GM_LTOD); + _MacOutVarD(x); + + x->ls.lmsd = 0; + x->ls.lsl[1] = 0L; + x->ls.lsl[0] = (l<0) ? -l : l; + x->ls.lid = 0; + x->ls.lattr = (l<0) ? 1 : 0; + + _MacRet(x); +} diff --git a/gfm/makeasm b/gfm/makeasm new file mode 100755 index 000000000..a65f4b3fc --- /dev/null +++ b/gfm/makeasm @@ -0,0 +1,743 @@ +CFLAGS=-I$(DEVHOME)/mathlib -Otlig -W2 + +all: objects objects1 objects2 objects3 + +objects : adatenly.o adate360.o adate365.o addarr.o addarrd.o adddfd.o addid.o addld.o addstr.o adduid.o adduld.o advpmt.o agmn.o amort.o amorttbl.o atod.o atodr.o bondprc.o bondyld.o comp.o compaux.o compcomp.o compsimp.o dabs.o dacos.o dadd.o dadx.o dalloc.o dalog.o daralloc.o darcpy.o darfree.o dasin.o datan.o datax.o dbd360.o dbd365.o dbdnly.o dchgs.o dchix.o dcmp.o dcos.o dcoss.o dcot.o dcox.o dcpy.o dctod.o ddeg.o ddiv.o ddivpf.o ddivpr.o ddivpt.o ddivr.o ddivt.o ddix.o ddixf.o ddixr.o ddixt.o deltrz.o dexp.o dexx.o dfact.o dfprintf.o dfract.o dfree.o dfscanf.o dftod.o dftodr.o dint.o + +objects1 : diseq.o disge.o disgt.o disint.o disle.o dislt.o disne.o disneg.o dispos.o diszero.o divarr.o divarrd.o divdfd.o divid.o divld.o divstr.o divuid.o divuld.o dln.o dlnx.o dlog.o dmag.o dmant.o dmax.o dmbyn.o dmbyp10.o dmbyp10t.o dmby1.o dmby1r.o dmean.o dmi.o dmin.o dmod.o dmoddf.o dmodi.o dmodl.o dmodui.o dmodul.o dmul.o dmulr.o dmult.o dmux.o dpct.o dpdb.o dpdbtbl.o dpddb.o dpddbtbl.o dpow.o dpowi.o dpowrat.o dpsl.o dpsltbl.o dpsoy.o dpsoytbl.o drad.o droot.o drooti.o dround.o dscanf.o dsetertn.o dsign.o dsin.o dsins.o dsort.o dsprintf.o dsqrt.o dsqx.o dsscanf.o dsub.o dsux.o dswap.o dtan.o dtoa.o dtoac.o dtodc.o dtoacr.o dtoaf.o dtoar.o + +objects2 : dtodf.o dtoeng.o dtofr.o dtoi.o dtol.o dtosci.o dtoui.o dtoul.o dtrunc.o dtrux.o dzero.o dzeroarr.o d10by5.o d10by5t.o efftonom.o errname.o funname.o frtod.o gcmp.o ginc.o gmec.o gmef.o gmglobal.o gmrs.o gmserri.o hmi.o intraux.o irr.o itod.o linest.o lookarr.o ltod.o makid.o makld.o makuid.o makuld.o maxarr.o median.o mgmn.o minarr.o mirr.o mli.o + +objects3 : mularr.o mularrd.o muldfd.o mulid.o mulld.o mulstr.o muluid.o mululd.o mul10.o mul10l.o mul10ad.o nfv.o nomtoeff.o npv.o padd.o pchange.o pdiv.o pmul.o pof.o predx.o predy.o psub.o ptoy.o roundcnt.o scanfx.o sgmn.o simpaux.o simp360.o simp365.o smi.o spfv.o sppv.o sq5to4.o stnddev.o subarr.o subarrd.o subdfd.o subid.o subld.o substr.o subuid.o subuld.o sumarr.o sumarrn.o sumarrp.o trunccnt.o uitod.o ultod.o usfv.o uspv.o wmean.o ytop.o dpoxi.o dprec.o dprintf.o + +adatenly.o: adatenly.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +adate360.o: adate360.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +adate365.o: adate365.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +addarr.o: addarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +addarrd.o: addarrd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +adddfd.o: adddfd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +addid.o: addid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +addld.o: addld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +addstr.o: addstr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +adduid.o: adduid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +adduld.o: adduld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +advpmt.o: advpmt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +agmn.o: agmn.asm prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +amort.o: amort.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +amorttbl.o: amorttbl.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +atod.o: atod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +atodr.o: atodr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +bondprc.o: bondprc.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +bondyld.o: bondyld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +comp.o: comp.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +compaux.o: compaux.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +compcomp.o: compcomp.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +compsimp.o: compsimp.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dabs.o: dabs.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dacos.o: dacos.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dadd.o: dadd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dadx.o: dadx.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dalloc.o: dalloc.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dalog.o: dalog.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +daralloc.o: daralloc.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +darcpy.o: darcpy.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +darfree.o: darfree.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dasin.o: dasin.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +datan.o: datan.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +datax.o: datax.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dbd360.o: dbd360.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dbd365.o: dbd365.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dbdnly.o: dbdnly.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dchgs.o: dchgs.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dchix.o: dchix.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dcmp.o: dcmp.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dcos.o: dcos.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dcoss.o: dcoss.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dcot.o: dcot.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dcox.o: dcox.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dcpy.o: dcpy.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dctod.o: dctod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddeg.o: ddeg.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddiv.o: ddiv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddivpf.o: ddivpf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddivpr.o: ddivpr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddivpt.o: ddivpt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddivr.o: ddivr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddivt.o: ddivt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddix.o: ddix.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddixf.o: ddixf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddixr.o: ddixr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ddixt.o: ddixt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +deltrz.o: deltrz.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dexp.o: dexp.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dexx.o: dexx.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dfact.o: dfact.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dfprintf.o: dfprintf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dfract.o: dfract.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dfree.o: dfree.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dfscanf.o: dfscanf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dftod.o: dftod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dftodr.o: dftodr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dint.o: dint.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +diseq.o: diseq.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +disge.o: disge.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +disgt.o: disgt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +disint.o: disint.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +disle.o: disle.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dislt.o: dislt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +disne.o: disne.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +disneg.o: disneg.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dispos.o: dispos.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +diszero.o: diszero.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divarr.o: divarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divarrd.o: divarrd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divdfd.o: divdfd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divid.o: divid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divld.o: divld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divstr.o: divstr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divuid.o: divuid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +divuld.o: divuld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dln.o: dln.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dlnx.o: dlnx.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dlog.o: dlog.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmag.o: dmag.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmant.o: dmant.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmax.o: dmax.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmbyn.o: dmbyn.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmbyp10.o: dmbyp10.c prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmbyp10t.o: dmbyp10t.c prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmby1.o: dmby1.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmby1r.o: dmby1r.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmean.o: dmean.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmi.o: dmi.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmin.o: dmin.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmod.o: dmod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmoddf.o: dmoddf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmodi.o: dmodi.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmodl.o: dmodl.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmodui.o: dmodui.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmodul.o: dmodul.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmul.o: dmul.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmulr.o: dmulr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmult.o: dmult.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dmux.o: dmux.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpct.o: dpct.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpdb.o: dpdb.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpdbtbl.o: dpdbtbl.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpddb.o: dpddb.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpddbtbl.o: dpddbtbl.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpow.o: dpow.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpowi.o: dpowi.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpowrat.o: dpowrat.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpoxi.o: dpoxi.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dprec.o: dprec.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dprintf.o: dprintf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpsl.o: dpsl.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpsltbl.o: dpsltbl.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpsoy.o: dpsoy.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dpsoytbl.o: dpsoytbl.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +drad.o: drad.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +droot.o: droot.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +drooti.o: drooti.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dround.o: dround.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dscanf.o: dscanf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsetertn.o: dsetertn.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsign.o: dsign.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsin.o: dsin.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsins.o: dsins.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsort.o: dsort.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsprintf.o: dsprintf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsqrt.o: dsqrt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsqx.o: dsqx.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsscanf.o: dsscanf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsub.o: dsub.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dsux.o: dsux.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dswap.o: dswap.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtan.o: dtan.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoa.o: dtoa.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoac.o: dtoac.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoacr.o: dtoacr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoaf.o: dtoaf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoar.o: dtoar.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtodc.o: dtodc.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtodf.o: dtodf.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoeng.o: dtoeng.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtofr.o: dtofr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoi.o: dtoi.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtol.o: dtol.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtosci.o: dtosci.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoui.o: dtoui.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtoul.o: dtoul.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtrunc.o: dtrunc.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dtrux.o: dtrux.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dzero.o: dzero.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +dzeroarr.o: dzeroarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +d10by5.o: d10by5.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +d10by5t.o: d10by5t.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +efftonom.o: efftonom.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +errname.o: errname.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +funname.o: funname.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +frtod.o: frtod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +gcmp.o: gcmp.c prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ginc.o: ginc.c prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +gmec.o: gmec.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +gmef.o: gmef.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +gmglobal.o: gmglobal.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +gmrs.o: gmrs.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +gmserri.o: gmserri.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +hmi.o: hmi.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +intraux.o: intraux.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +irr.o: irr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +itod.o: itod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +linest.o: linest.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +lookarr.o: lookarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ltod.o: ltod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +makid.o: makid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +makld.o: makld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +makuid.o: makuid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +makuld.o: makuld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +maxarr.o: maxarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +median.o: median.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mgmn.o: mgmn.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +minarr.o: minarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mirr.o: mirr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mli.o: mli.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mularr.o: mularr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mularrd.o: mularrd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +muldfd.o: muldfd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mulid.o: mulid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mulld.o: mulld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mulstr.o: mulstr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +muluid.o: muluid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mululd.o: mululd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mul10.o: mul10.c prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mul10l.o: mul10l.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +mul10ad.o: mul10ad.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +nfv.o: nfv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +nomtoeff.o: nomtoeff.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +npv.o: npv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +padd.o: padd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +pchange.o: pchange.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +pdiv.o: pdiv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +pmul.o: pmul.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +pof.o: pof.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +predx.o: predx.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +predy.o: predy.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ptoy.o: ptoy.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +roundcnt.o: roundcnt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +psub.o: psub.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +scanfx.o: scanfx.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +sgmn.o: sgmn.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +simpaux.o: simpaux.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +simp360.o: simp360.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +simp365.o: simp365.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +smi.o: smi.c gmsys1.h prologue.h model.h gm.equ + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +spfv.o: spfv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +sppv.o: sppv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +sq5to4.o: sq5to4.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +stnddev.o: stnddev.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +subarr.o: subarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +subarrd.o: subarrd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +subdfd.o: subdfd.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +subid.o: subid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +subld.o: subld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +substr.o: substr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +subuid.o: subuid.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +subuld.o: subuld.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +sumarr.o: sumarr.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +sumarrn.o: sumarrn.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +sumarrp.o: sumarrp.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +trunccnt.o: trunccnt.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +uitod.o: uitod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ultod.o: ultod.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +usfv.o: usfv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +uspv.o: uspv.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +wmean.o: wmean.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c + +ytop.o: ytop.c + cc -I/disk1/mathlib -c -Fa$(@F:.o= ).aaa $(@F:.o= ).c diff --git a/gfm/makefile b/gfm/makefile new file mode 100755 index 000000000..abb1ce562 --- /dev/null +++ b/gfm/makefile @@ -0,0 +1,513 @@ +.c.a: + $(CCOMP) -c $(<:.c= ) + ar rcvn $@ $*.o + rm -f $*.o + +.asm.a: + masm -Ml $< + ar rcvn $@ $*.o + rm -f $*.o + +mathlib : $(LIB1) $(LIB2) + +.PRECIOUS : $(LIB1) $(LIB2) + +$(LIB1) : $(LIB1)(adatenly.o) $(LIB1)(adate360.o) $(LIB1)(adate365.o) $(LIB1)(addarr.o) $(LIB1)(addarrd.o) $(LIB1)(adddfd.o) $(LIB1)(addid.o) $(LIB1)(addld.o) $(LIB1)(addstr.o) $(LIB1)(adduid.o) $(LIB1)(adduld.o) $(LIB1)(advpmt.o) $(LIB1)(agmn.o) $(LIB1)(amort.o) $(LIB1)(amorttbl.o) $(LIB1)(atod.o) $(LIB1)(atodr.o) $(LIB1)(bondprc.o) $(LIB1)(bondyld.o) $(LIB1)(comp.o) $(LIB1)(compaux.o) $(LIB1)(compcomp.o) $(LIB1)(compsimp.o) $(LIB1)(dabs.o) $(LIB1)(dacos.o) $(LIB1)(dadd.o) $(LIB1)(dadx.o) $(LIB1)(dalloc.o) $(LIB1)(dalog.o) $(LIB1)(daralloc.o) $(LIB1)(darcpy.o) $(LIB1)(darfree.o) $(LIB1)(dasin.o) $(LIB1)(datan.o) $(LIB1)(datax.o) $(LIB1)(dbd360.o) $(LIB1)(dbd365.o) \ +$(LIB1)(dbdnly.o) $(LIB1)(dchgs.o) $(LIB1)(dchix.o) $(LIB1)(dcmp.o) $(LIB1)(dcos.o) $(LIB1)(dcoss.o) $(LIB1)(dcot.o) $(LIB1)(dcox.o) $(LIB1)(dcpy.o) $(LIB1)(dctod.o) $(LIB1)(ddeg.o) $(LIB1)(ddiv.o) $(LIB1)(ddivpf.o) $(LIB1)(ddivpr.o) $(LIB1)(ddivpt.o) $(LIB1)(ddivr.o) $(LIB1)(ddivt.o) $(LIB1)(ddix.o) $(LIB1)(ddixf.o) $(LIB1)(ddixr.o) $(LIB1)(ddixt.o) $(LIB1)(deltrz.o) $(LIB1)(dexp.o) $(LIB1)(dexx.o) $(LIB1)(dfact.o) $(LIB1)(dfprintf.o) $(LIB1)(dfract.o) $(LIB1)(dfree.o) $(LIB1)(dfscanf.o) $(LIB1)(dftod.o) $(LIB1)(dftodr.o) $(LIB1)(dint.o) $(LIB1)(diseq.o) $(LIB1)(disge.o) \ +$(LIB1)(disgt.o) $(LIB1)(disint.o) $(LIB1)(disle.o) $(LIB1)(dislt.o) $(LIB1)(disne.o) $(LIB1)(disneg.o) $(LIB1)(dispos.o) $(LIB1)(diszero.o) $(LIB1)(divarr.o) $(LIB1)(divarrd.o) $(LIB1)(divdfd.o) $(LIB1)(divid.o) $(LIB1)(divld.o) $(LIB1)(divstr.o) $(LIB1)(divuid.o) $(LIB1)(divuld.o) $(LIB1)(dln.o) $(LIB1)(dlnx.o) $(LIB1)(dlog.o) $(LIB1)(dmag.o) $(LIB1)(dmant.o) $(LIB1)(dmax.o) $(LIB1)(dmbyn.o) $(LIB1)(dmbyp10.o) $(LIB1)(dmbyp10t.o) $(LIB1)(dmby1.o) $(LIB1)(dmby1r.o) $(LIB1)(dmean.o) $(LIB1)(dmi.o) $(LIB1)(dmin.o) $(LIB1)(dmod.o) $(LIB1)(dmoddf.o) $(LIB1)(dmodi.o) $(LIB1)(dmodl.o) \ +$(LIB1)(dmodui.o) $(LIB1)(dmodul.o) $(LIB1)(dmul.o) $(LIB1)(dmulr.o) $(LIB1)(dmult.o) $(LIB1)(dmux.o) $(LIB1)(dpct.o) $(LIB1)(dpdb.o) $(LIB1)(dpdbtbl.o) $(LIB1)(dpddb.o) $(LIB1)(dpddbtbl.o) $(LIB1)(dpow.o) $(LIB1)(dpowi.o) $(LIB1)(dpowrat.o) $(LIB1)(dpsl.o) $(LIB1)(dpsltbl.o) $(LIB1)(dpsoy.o) $(LIB1)(dpsoytbl.o) $(LIB1)(drad.o) $(LIB1)(droot.o) $(LIB1)(drooti.o) $(LIB1)(dround.o) $(LIB1)(dscanf.o) $(LIB1)(dsetertn.o) $(LIB1)(dsign.o) $(LIB1)(dsin.o) $(LIB1)(dsins.o) $(LIB1)(dsort.o) $(LIB1)(dsprintf.o) $(LIB1)(dsqrt.o) $(LIB1)(dsqx.o) $(LIB1)(dsscanf.o) $(LIB1)(dsub.o) $(LIB1)(dsux.o) + ranlib $(LIB1) + +$(LIB2) : $(LIB2)(dswap.o) $(LIB2)(dtan.o) $(LIB2)(dtoa.o) $(LIB2)(dtoac.o) $(LIB2)(dtodc.o) $(LIB2)(dtoacr.o) $(LIB2)(dtoaf.o) $(LIB2)(dtoar.o) $(LIB2)(dtodf.o) $(LIB2)(dtoeng.o) $(LIB2)(dtofr.o) $(LIB2)(dtoi.o) $(LIB2)(dtol.o) $(LIB2)(dtosci.o) $(LIB2)(dtoui.o) $(LIB2)(dtoul.o) $(LIB2)(dtrunc.o) $(LIB2)(dtrux.o) $(LIB2)(dzero.o) $(LIB2)(dzeroarr.o) $(LIB2)(d10by5.o) $(LIB2)(d10by5t.o) $(LIB2)(efftonom.o) $(LIB2)(errname.o) $(LIB2)(funname.o) $(LIB2)(frtod.o) $(LIB2)(gcmp.o) $(LIB2)(ginc.o) $(LIB2)(gmec.o) $(LIB2)(gmef.o) $(LIB2)(gmglobal.o) $(LIB2)(gmrs.o) $(LIB2)(gmserri.o) $(LIB2)(hmi.o) \ +$(LIB2)(intraux.o) $(LIB2)(irr.o) $(LIB2)(itod.o) $(LIB2)(linest.o) $(LIB2)(lookarr.o) $(LIB2)(ltod.o) $(LIB2)(makid.o) $(LIB2)(makld.o) $(LIB2)(makuid.o) $(LIB2)(makuld.o) $(LIB2)(maxarr.o) $(LIB2)(median.o) $(LIB2)(mgmn.o) $(LIB2)(minarr.o) $(LIB2)(mirr.o) $(LIB2)(mli.o) $(LIB2)(mularr.o) $(LIB2)(mularrd.o) $(LIB2)(muldfd.o) $(LIB2)(mulid.o) $(LIB2)(mulld.o) $(LIB2)(mulstr.o) $(LIB2)(muluid.o) $(LIB2)(mululd.o) $(LIB2)(mul10.o) $(LIB2)(mul10l.o) $(LIB2)(mul10ad.o) $(LIB2)(nfv.o) $(LIB2)(nomtoeff.o) $(LIB2)(npv.o) $(LIB2)(padd.o) \ +$(LIB2)(pchange.o) $(LIB2)(pdiv.o) $(LIB2)(pmul.o) $(LIB2)(pof.o) $(LIB2)(predx.o) $(LIB2)(predy.o) $(LIB2)(psub.o) $(LIB2)(ptoy.o) $(LIB2)(roundcnt.o) $(LIB2)(scanfx.o) $(LIB2)(sgmn.o) $(LIB2)(simpaux.o) $(LIB2)(simp360.o) $(LIB2)(simp365.o) $(LIB2)(smi.o) $(LIB2)(spfv.o) $(LIB2)(sppv.o) $(LIB2)(sq5to4.o) $(LIB2)(stnddev.o) $(LIB2)(subarr.o) $(LIB2)(subarrd.o) $(LIB2)(subdfd.o) $(LIB2)(subid.o) $(LIB2)(subld.o) $(LIB2)(substr.o) $(LIB2)(subuid.o) $(LIB2)(subuld.o) $(LIB2)(sumarr.o) $(LIB2)(sumarrn.o) $(LIB2)(sumarrp.o) $(LIB2)(trunccnt.o) $(LIB2)(uitod.o) $(LIB2)(ultod.o) $(LIB2)(usfv.o) $(LIB2)(uspv.o) $(LIB2)(wmean.o) $(LIB2)(ytop.o) $(LIB2)(dpoxi.o) $(LIB2)(dprec.o) $(LIB2)(dprintf.o) + ranlib $(LIB2) + +$(LIB1)(adatenly.o): adatenly.c + +$(LIB1)(adate360.o): adate360.c + +$(LIB1)(adate365.o): adate365.c + +$(LIB1)(addarr.o): addarr.c + +$(LIB1)(addarrd.o): addarrd.c + +$(LIB1)(adddfd.o): adddfd.c + +$(LIB1)(addid.o): addid.c + +$(LIB1)(addld.o): addld.c + +$(LIB1)(addstr.o): addstr.c + +$(LIB1)(adduid.o): adduid.c + +$(LIB1)(adduld.o): adduld.c + +$(LIB1)(advpmt.o): advpmt.c + +$(LIB1)(agmn.o): agmn.asm prologue.h model.h gm.equ + +$(LIB1)(amort.o): amort.c + +$(LIB1)(amorttbl.o): amorttbl.c + +$(LIB1)(atod.o): atod.c + +$(LIB1)(atodr.o): atodr.c + +$(LIB1)(bondprc.o): bondprc.c + +$(LIB1)(bondyld.o): bondyld.c + +$(LIB1)(comp.o): comp.c + +$(LIB1)(compaux.o): compaux.c + +$(LIB1)(compcomp.o): compcomp.c + +$(LIB1)(compsimp.o): compsimp.c + +$(LIB1)(dabs.o): dabs.c + +$(LIB1)(dacos.o): dacos.c + +$(LIB1)(dadd.o): dadd.c + +$(LIB1)(dadx.o): dadx.c + +$(LIB1)(dalloc.o): dalloc.c + +$(LIB1)(dalog.o): dalog.c + +$(LIB1)(daralloc.o): daralloc.c + +$(LIB1)(darcpy.o): darcpy.c + +$(LIB1)(darfree.o): darfree.c + +$(LIB1)(dasin.o): dasin.c + +$(LIB1)(datan.o): datan.c + +$(LIB1)(datax.o): datax.c + +$(LIB1)(dbd360.o): dbd360.c + +$(LIB1)(dbd365.o): dbd365.c + +$(LIB1)(dbdnly.o): dbdnly.c + +$(LIB1)(dchgs.o): dchgs.c + +$(LIB1)(dchix.o): dchix.c + +$(LIB1)(dcmp.o): dcmp.c + +$(LIB1)(dcos.o): dcos.c + +$(LIB1)(dcoss.o): dcoss.c + +$(LIB1)(dcot.o): dcot.c + +$(LIB1)(dcox.o): dcox.c + +$(LIB1)(dcpy.o): dcpy.c + +$(LIB1)(dctod.o): dctod.c + +$(LIB1)(ddeg.o): ddeg.c + +$(LIB1)(ddiv.o): ddiv.c + +$(LIB1)(ddivpf.o): ddivpf.c + +$(LIB1)(ddivpr.o): ddivpr.c + +$(LIB1)(ddivpt.o): ddivpt.c + +$(LIB1)(ddivr.o): ddivr.c + +$(LIB1)(ddivt.o): ddivt.c + +$(LIB1)(ddix.o): ddix.c + +$(LIB1)(ddixf.o): ddixf.c + +$(LIB1)(ddixr.o): ddixr.c + +$(LIB1)(ddixt.o): ddixt.c + +$(LIB1)(deltrz.o): deltrz.c + +$(LIB1)(dexp.o): dexp.c + +$(LIB1)(dexx.o): dexx.c + +$(LIB1)(dfact.o): dfact.c + +$(LIB1)(dfprintf.o): dfprintf.c + +$(LIB1)(dfract.o): dfract.c + +$(LIB1)(dfree.o): dfree.c + +$(LIB1)(dfscanf.o): dfscanf.c + +$(LIB1)(dftod.o): dftod.c + +$(LIB1)(dftodr.o): dftodr.c + +$(LIB1)(dint.o): dint.c + +$(LIB1)(diseq.o): diseq.c + +$(LIB1)(disge.o): disge.c + +$(LIB1)(disgt.o): disgt.c + +$(LIB1)(disint.o): disint.c + +$(LIB1)(disle.o): disle.c + +$(LIB1)(dislt.o): dislt.c + +$(LIB1)(disne.o): disne.c + +$(LIB1)(disneg.o): disneg.c + +$(LIB1)(dispos.o): dispos.c + +$(LIB1)(diszero.o): diszero.c + +$(LIB1)(divarr.o): divarr.c + +$(LIB1)(divarrd.o): divarrd.c + +$(LIB1)(divdfd.o): divdfd.c + +$(LIB1)(divid.o): divid.c + +$(LIB1)(divld.o): divld.c + +$(LIB1)(divstr.o): divstr.c + +$(LIB1)(divuid.o): divuid.c + +$(LIB1)(divuld.o): divuld.c + +$(LIB1)(dln.o): dln.c + +$(LIB1)(dlnx.o): dlnx.c + +$(LIB1)(dlog.o): dlog.c + +$(LIB1)(dmag.o): dmag.c + +$(LIB1)(dmant.o): dmant.c + +$(LIB1)(dmax.o): dmax.c + +$(LIB1)(dmbyn.o): dmbyn.asm prologue.h model.h gm.equ + +$(LIB1)(dmbyp10.o): dmbyp10.asm prologue.h model.h gm.equ + +$(LIB1)(dmbyp10t.o): dmbyp10t.asm prologue.h model.h gm.equ + +$(LIB1)(dmby1.o): dmby1.asm prologue.h model.h gm.equ + +$(LIB1)(dmby1r.o): dmby1r.asm prologue.h model.h gm.equ + +$(LIB1)(dmean.o): dmean.c + +$(LIB1)(dmi.o): dmi.asm prologue.h model.h gm.equ + +$(LIB1)(dmin.o): dmin.c + +$(LIB1)(dmod.o): dmod.c + +$(LIB1)(dmoddf.o): dmoddf.c + +$(LIB1)(dmodi.o): dmodi.c + +$(LIB1)(dmodl.o): dmodl.c + +$(LIB1)(dmodui.o): dmodui.c + +$(LIB1)(dmodul.o): dmodul.c + +$(LIB1)(dmul.o): dmul.c + +$(LIB1)(dmulr.o): dmulr.c + +$(LIB1)(dmult.o): dmult.c + +$(LIB1)(dmux.o): dmux.c + +$(LIB1)(dpct.o): dpct.c + +$(LIB1)(dpdb.o): dpdb.c + +$(LIB1)(dpdbtbl.o): dpdbtbl.c + +$(LIB1)(dpddb.o): dpddb.c + +$(LIB1)(dpddbtbl.o): dpddbtbl.c + +$(LIB1)(dpow.o): dpow.c + +$(LIB1)(dpowi.o): dpowi.c + +$(LIB1)(dpowrat.o): dpowrat.c + +$(LIB1)(dpoxi.o): dpoxi.c + +$(LIB1)(dprec.o): dprec.c + +$(LIB1)(dprintf.o): dprintf.c + +$(LIB1)(dpsl.o): dpsl.c + +$(LIB1)(dpsltbl.o): dpsltbl.c + +$(LIB1)(dpsoy.o): dpsoy.c + +$(LIB1)(dpsoytbl.o): dpsoytbl.c + +$(LIB1)(drad.o): drad.c + +$(LIB1)(droot.o): droot.c + +$(LIB1)(drooti.o): drooti.c + +$(LIB1)(dround.o): dround.c + +$(LIB1)(dscanf.o): dscanf.c + +$(LIB1)(dsetertn.o): dsetertn.c + +$(LIB1)(dsign.o): dsign.c + +$(LIB1)(dsin.o): dsin.c + +$(LIB1)(dsins.o): dsins.c + +$(LIB1)(dsort.o): dsort.c + +$(LIB1)(dsprintf.o): dsprintf.c + +$(LIB1)(dsqrt.o): dsqrt.c + +$(LIB1)(dsqx.o): dsqx.c + +$(LIB1)(dsscanf.o): dsscanf.c + +$(LIB1)(dsub.o): dsub.c + +$(LIB1)(dsux.o): dsux.c + +$(LIB2)(dswap.o): dswap.c + +$(LIB2)(dtan.o): dtan.c + +$(LIB2)(dtoa.o): dtoa.c + +$(LIB2)(dtoac.o): dtoac.c + +$(LIB2)(dtoacr.o): dtoacr.c + +$(LIB2)(dtoaf.o): dtoaf.c + +$(LIB2)(dtoar.o): dtoar.c + +$(LIB2)(dtodc.o): dtodc.c + +$(LIB2)(dtodf.o): dtodf.c + +$(LIB2)(dtoeng.o): dtoeng.c + +$(LIB2)(dtofr.o): dtofr.c + +$(LIB2)(dtoi.o): dtoi.c + +$(LIB2)(dtol.o): dtol.c + +$(LIB2)(dtosci.o): dtosci.c + +$(LIB2)(dtoui.o): dtoui.c + +$(LIB2)(dtoul.o): dtoul.c + +$(LIB2)(dtrunc.o): dtrunc.c + +$(LIB2)(dtrux.o): dtrux.c + +$(LIB2)(dzero.o): dzero.c + +$(LIB2)(dzeroarr.o): dzeroarr.c + +$(LIB2)(d10by5.o): d10by5.c + +$(LIB2)(d10by5t.o): d10by5t.c + +$(LIB2)(efftonom.o): efftonom.c + +$(LIB2)(errname.o): errname.c + +$(LIB2)(funname.o): funname.c + +$(LIB2)(frtod.o): frtod.c + +$(LIB2)(gcmp.o): gcmp.asm prologue.h model.h gm.equ + +$(LIB2)(ginc.o): ginc.asm prologue.h model.h gm.equ + +$(LIB2)(gmec.o): gmec.c + +$(LIB2)(gmef.o): gmef.c + +$(LIB2)(gmglobal.o): gmglobal.c + +$(LIB2)(gmrs.o): gmrs.c + +$(LIB2)(gmserri.o): gmserri.c + +$(LIB2)(hmi.o): hmi.asm prologue.h model.h gm.equ + +$(LIB2)(intraux.o): intraux.c + +$(LIB2)(irr.o): irr.c + +$(LIB2)(itod.o): itod.c + +$(LIB2)(linest.o): linest.c + +$(LIB2)(lookarr.o): lookarr.c + +$(LIB2)(ltod.o): ltod.c + +$(LIB2)(makid.o): makid.c + +$(LIB2)(makld.o): makld.c + +$(LIB2)(makuid.o): makuid.c + +$(LIB2)(makuld.o): makuld.c + +$(LIB2)(maxarr.o): maxarr.c + +$(LIB2)(median.o): median.c + +$(LIB2)(mgmn.o): mgmn.asm prologue.h model.h gm.equ + +$(LIB2)(minarr.o): minarr.c + +$(LIB2)(mirr.o): mirr.c + +$(LIB2)(mli.o): mli.asm prologue.h model.h gm.equ + +$(LIB2)(mularr.o): mularr.c + +$(LIB2)(mularrd.o): mularrd.c + +$(LIB2)(muldfd.o): muldfd.c + +$(LIB2)(mulid.o): mulid.c + +$(LIB2)(mulld.o): mulld.c + +$(LIB2)(mulstr.o): mulstr.c + +$(LIB2)(muluid.o): muluid.c + +$(LIB2)(mululd.o): mululd.c + +$(LIB2)(mul10.o): mul10.asm prologue.h model.h gm.equ + +$(LIB2)(mul10l.o): mul10l.asm prologue.h model.h gm.equ + +$(LIB2)(mul10ad.o): mul10ad.asm prologue.h model.h gm.equ + +$(LIB2)(nfv.o): nfv.c + +$(LIB2)(nomtoeff.o): nomtoeff.c + +$(LIB2)(npv.o): npv.c + +$(LIB2)(padd.o): padd.c + +$(LIB2)(pchange.o): pchange.c + +$(LIB2)(pdiv.o): pdiv.c + +$(LIB2)(pmul.o): pmul.c + +$(LIB2)(pof.o): pof.c + +$(LIB2)(predx.o): predx.c + +$(LIB2)(predy.o): predy.c + +$(LIB2)(ptoy.o): ptoy.c + +$(LIB2)(roundcnt.o): roundcnt.c + +$(LIB2)(psub.o): psub.c + +$(LIB2)(scanfx.o): scanfx.c + +$(LIB2)(sgmn.o): sgmn.asm prologue.h model.h gm.equ + +$(LIB2)(simpaux.o): simpaux.c + +$(LIB2)(simp360.o): simp360.c + +$(LIB2)(simp365.o): simp365.c + +$(LIB2)(smi.o): smi.asm prologue.h model.h gm.equ + +$(LIB2)(spfv.o): spfv.c + +$(LIB2)(sppv.o): sppv.c + +$(LIB2)(sq5to4.o): sq5to4.c + +$(LIB2)(stnddev.o): stnddev.c + +$(LIB2)(subarr.o): subarr.c + +$(LIB2)(subarrd.o): subarrd.c + +$(LIB2)(subdfd.o): subdfd.c + +$(LIB2)(subid.o): subid.c + +$(LIB2)(subld.o): subld.c + +$(LIB2)(substr.o): substr.c + +$(LIB2)(subuid.o): subuid.c + +$(LIB2)(subuld.o): subuld.c + +$(LIB2)(sumarr.o): sumarr.c + +$(LIB2)(sumarrn.o): sumarrn.c + +$(LIB2)(sumarrp.o): sumarrp.c + +$(LIB2)(trunccnt.o): trunccnt.c + +$(LIB2)(uitod.o): uitod.c + +$(LIB2)(ultod.o): ultod.c + +$(LIB2)(usfv.o): usfv.c + +$(LIB2)(uspv.o): uspv.c + +$(LIB2)(wmean.o): wmean.c + +$(LIB2)(ytop.o): ytop.c + diff --git a/gfm/makefile3 b/gfm/makefile3 new file mode 100755 index 000000000..571ed4208 --- /dev/null +++ b/gfm/makefile3 @@ -0,0 +1,509 @@ +.c.a: + $(CCOMP) $(FLAGS) $(<:.c= ) + ar rcv $@ $*.o + rm -f $*.o + +mathlib : $(LIB1) $(LIB2) + +.PRECIOUS : $(LIB1) $(LIB2) + +$(LIB1) : $(LIB1)(adatenly.o) $(LIB1)(adate360.o) $(LIB1)(adate365.o) $(LIB1)(addarr.o) $(LIB1)(addarrd.o) $(LIB1)(adddfd.o) $(LIB1)(addid.o) $(LIB1)(addld.o) $(LIB1)(addstr.o) $(LIB1)(adduid.o) $(LIB1)(adduld.o) $(LIB1)(advpmt.o) $(LIB1)(agmn.o) $(LIB1)(amort.o) \ +$(LIB1)(amorttbl.o) $(LIB1)(atod.o) $(LIB1)(atodr.o) $(LIB1)(bondprc.o) $(LIB1)(bondyld.o) $(LIB1)(comp.o) $(LIB1)(compaux.o) $(LIB1)(compcomp.o) $(LIB1)(compsimp.o) $(LIB1)(dabs.o) $(LIB1)(dacos.o) $(LIB1)(dadd.o) $(LIB1)(dadx.o) $(LIB1)(dalloc.o) $(LIB1)(dalog.o) $(LIB1)(daralloc.o) $(LIB1)(darcpy.o) $(LIB1)(darfree.o) $(LIB1)(dasin.o) $(LIB1)(datan.o) $(LIB1)(datax.o) $(LIB1)(dbd360.o) $(LIB1)(dbd365.o) \ +$(LIB1)(dbdnly.o) $(LIB1)(dchgs.o) $(LIB1)(dchix.o) $(LIB1)(dcmp.o) $(LIB1)(dcos.o) $(LIB1)(dcoss.o) $(LIB1)(dcot.o) $(LIB1)(dcox.o) $(LIB1)(dcpy.o) $(LIB1)(dctod.o) $(LIB1)(ddeg.o) $(LIB1)(ddiv.o) $(LIB1)(ddivpf.o) $(LIB1)(ddivpr.o) $(LIB1)(ddivpt.o) $(LIB1)(ddivr.o) $(LIB1)(ddivt.o) $(LIB1)(ddix.o) $(LIB1)(ddixf.o) $(LIB1)(ddixr.o) $(LIB1)(ddixt.o) $(LIB1)(deltrz.o) $(LIB1)(dexp.o) $(LIB1)(dexx.o) $(LIB1)(dfact.o) $(LIB1)(dfprintf.o) $(LIB1)(dfract.o) $(LIB1)(dfree.o) $(LIB1)(dfscanf.o) $(LIB1)(dftod.o) $(LIB1)(dftodr.o) $(LIB1)(dint.o) $(LIB1)(diseq.o) $(LIB1)(disge.o) \ +$(LIB1)(disgt.o) $(LIB1)(disint.o) $(LIB1)(disle.o) $(LIB1)(dislt.o) $(LIB1)(disne.o) $(LIB1)(disneg.o) $(LIB1)(dispos.o) $(LIB1)(diszero.o) $(LIB1)(divarr.o) $(LIB1)(divarrd.o) $(LIB1)(divdfd.o) $(LIB1)(divid.o) $(LIB1)(divld.o) $(LIB1)(divstr.o) $(LIB1)(divuid.o) $(LIB1)(divuld.o) $(LIB1)(dln.o) $(LIB1)(dlnx.o) $(LIB1)(dlog.o) $(LIB1)(dmag.o) $(LIB1)(dmant.o) $(LIB1)(dmax.o) $(LIB1)(dmbyn.o) $(LIB1)(dmbyp10.o) $(LIB1)(dmbyp10t.o) $(LIB1)(dmby1.o) $(LIB1)(dmby1r.o) $(LIB1)(dmean.o) $(LIB1)(dmi.o) $(LIB1)(dmin.o) $(LIB1)(dmod.o) $(LIB1)(dmoddf.o) $(LIB1)(dmodi.o) $(LIB1)(dmodl.o) \ +$(LIB1)(dmodui.o) $(LIB1)(dmodul.o) $(LIB1)(dmul.o) $(LIB1)(dmulr.o) $(LIB1)(dmult.o) $(LIB1)(dmux.o) $(LIB1)(dpct.o) $(LIB1)(dpdb.o) $(LIB1)(dpdbtbl.o) $(LIB1)(dpddb.o) $(LIB1)(dpddbtbl.o) $(LIB1)(dpow.o) $(LIB1)(dpowi.o) $(LIB1)(dpowrat.o) $(LIB1)(dpsl.o) $(LIB1)(dpsltbl.o) $(LIB1)(dpsoy.o) $(LIB1)(dpsoytbl.o) $(LIB1)(drad.o) $(LIB1)(droot.o) $(LIB1)(drooti.o) $(LIB1)(dround.o) $(LIB1)(dscanf.o) $(LIB1)(dsetertn.o) $(LIB1)(dsign.o) $(LIB1)(dsin.o) $(LIB1)(dsins.o) $(LIB1)(dsort.o) $(LIB1)(dsprintf.o) $(LIB1)(dsqrt.o) $(LIB1)(dsqx.o) $(LIB1)(dsscanf.o) $(LIB1)(dsub.o) $(LIB1)(dsux.o) + ranlib $(LIB1) + +$(LIB2) : $(LIB2)(dswap.o) $(LIB2)(dtan.o) $(LIB2)(dtoa.o) $(LIB2)(dtoac.o) $(LIB2)(dtodc.o) $(LIB2)(dtoacr.o) $(LIB2)(dtoaf.o) $(LIB2)(dtoar.o) $(LIB2)(dtodf.o) $(LIB2)(dtoeng.o) $(LIB2)(dtofr.o) $(LIB2)(dtoi.o) $(LIB2)(dtol.o) $(LIB2)(dtosci.o) $(LIB2)(dtoui.o) $(LIB2)(dtoul.o) $(LIB2)(dtrunc.o) $(LIB2)(dtrux.o) $(LIB2)(dzero.o) $(LIB2)(dzeroarr.o) $(LIB2)(d10by5.o) $(LIB2)(d10by5t.o) $(LIB2)(efftonom.o) $(LIB2)(errname.o) $(LIB2)(funname.o) $(LIB2)(frtod.o) $(LIB2)(gcmp.o) $(LIB2)(ginc.o) $(LIB2)(gmec.o) $(LIB2)(gmef.o) $(LIB2)(gmglobal.o) $(LIB2)(gmrs.o) $(LIB2)(gmserri.o) $(LIB2)(hmi.o) \ +$(LIB2)(intraux.o) $(LIB2)(irr.o) $(LIB2)(itod.o) $(LIB2)(linest.o) $(LIB2)(lookarr.o) $(LIB2)(ltod.o) $(LIB2)(makid.o) $(LIB2)(makld.o) $(LIB2)(makuid.o) $(LIB2)(makuld.o) $(LIB2)(maxarr.o) $(LIB2)(median.o) $(LIB2)(mgmn.o) $(LIB2)(minarr.o) $(LIB2)(mirr.o) $(LIB2)(mli.o) $(LIB2)(mularr.o) $(LIB2)(mularrd.o) $(LIB2)(muldfd.o) $(LIB2)(mulid.o) $(LIB2)(mulld.o) $(LIB2)(mulstr.o) $(LIB2)(muluid.o) $(LIB2)(mululd.o) $(LIB2)(mul10.o) $(LIB2)(mul10l.o) $(LIB2)(mul10ad.o) $(LIB2)(nfv.o) $(LIB2)(nomtoeff.o) $(LIB2)(npv.o) $(LIB2)(padd.o) \ +$(LIB2)(pchange.o) $(LIB2)(pdiv.o) $(LIB2)(pmul.o) $(LIB2)(pof.o) $(LIB2)(predx.o) $(LIB2)(predy.o) $(LIB2)(psub.o) $(LIB2)(ptoy.o) $(LIB2)(roundcnt.o) $(LIB2)(scanfx.o) $(LIB2)(sgmn.o) $(LIB2)(simpaux.o) $(LIB2)(simp360.o) $(LIB2)(simp365.o) $(LIB2)(smi.o) $(LIB2)(spfv.o) $(LIB2)(sppv.o) $(LIB2)(sq5to4.o) $(LIB2)(stnddev.o) $(LIB2)(subarr.o) $(LIB2)(subarrd.o) $(LIB2)(subdfd.o) $(LIB2)(subid.o) $(LIB2)(subld.o) $(LIB2)(substr.o) $(LIB2)(subuid.o) $(LIB2)(subuld.o) $(LIB2)(sumarr.o) $(LIB2)(sumarrn.o) $(LIB2)(sumarrp.o) $(LIB2)(trunccnt.o) $(LIB2)(uitod.o) $(LIB2)(ultod.o) $(LIB2)(usfv.o) $(LIB2)(uspv.o) $(LIB2)(wmean.o) $(LIB2)(ytop.o) $(LIB2)(dpoxi.o) $(LIB2)(dprec.o) $(LIB2)(dprintf.o) + ranlib $(LIB2) + +$(LIB1)(adatenly.o): adatenly.c + +$(LIB1)(adate360.o): adate360.c + +$(LIB1)(adate365.o): adate365.c + +$(LIB1)(addarr.o): addarr.c + +$(LIB1)(addarrd.o): addarrd.c + +$(LIB1)(adddfd.o): adddfd.c + +$(LIB1)(addid.o): addid.c + +$(LIB1)(addld.o): addld.c + +$(LIB1)(addstr.o): addstr.c + +$(LIB1)(adduid.o): adduid.c + +$(LIB1)(adduld.o): adduld.c + +$(LIB1)(advpmt.o): advpmt.c + +$(LIB1)(agmn.o): agmn.c gmsys1.h prologue.h model.h gm.equ + +$(LIB1)(amort.o): amort.c + +$(LIB1)(amorttbl.o): amorttbl.c + +$(LIB1)(atod.o): atod.c + +$(LIB1)(atodr.o): atodr.c + +$(LIB1)(bondprc.o): bondprc.c + +$(LIB1)(bondyld.o): bondyld.c + +$(LIB1)(comp.o): comp.c + +$(LIB1)(compaux.o): compaux.c + +$(LIB1)(compcomp.o): compcomp.c + +$(LIB1)(compsimp.o): compsimp.c + +$(LIB1)(dabs.o): dabs.c + +$(LIB1)(dacos.o): dacos.c + +$(LIB1)(dadd.o): dadd.c + +$(LIB1)(dadx.o): dadx.c + +$(LIB1)(dalloc.o): dalloc.c + +$(LIB1)(dalog.o): dalog.c + +$(LIB1)(daralloc.o): daralloc.c + +$(LIB1)(darcpy.o): darcpy.c + +$(LIB1)(darfree.o): darfree.c + +$(LIB1)(dasin.o): dasin.c + +$(LIB1)(datan.o): datan.c + +$(LIB1)(datax.o): datax.c + +$(LIB1)(dbd360.o): dbd360.c + +$(LIB1)(dbd365.o): dbd365.c + +$(LIB1)(dbdnly.o): dbdnly.c + +$(LIB1)(dchgs.o): dchgs.c + +$(LIB1)(dchix.o): dchix.c + +$(LIB1)(dcmp.o): dcmp.c + +$(LIB1)(dcos.o): dcos.c + +$(LIB1)(dcoss.o): dcoss.c + +$(LIB1)(dcot.o): dcot.c + +$(LIB1)(dcox.o): dcox.c + +$(LIB1)(dcpy.o): dcpy.c + +$(LIB1)(dctod.o): dctod.c + +$(LIB1)(ddeg.o): ddeg.c + +$(LIB1)(ddiv.o): ddiv.c + +$(LIB1)(ddivpf.o): ddivpf.c + +$(LIB1)(ddivpr.o): ddivpr.c + +$(LIB1)(ddivpt.o): ddivpt.c + +$(LIB1)(ddivr.o): ddivr.c + +$(LIB1)(ddivt.o): ddivt.c + +$(LIB1)(ddix.o): ddix.c + +$(LIB1)(ddixf.o): ddixf.c + +$(LIB1)(ddixr.o): ddixr.c + +$(LIB1)(ddixt.o): ddixt.c + +$(LIB1)(deltrz.o): deltrz.c + +$(LIB1)(dexp.o): dexp.c + +$(LIB1)(dexx.o): dexx.c + +$(LIB1)(dfact.o): dfact.c + +$(LIB1)(dfprintf.o): dfprintf.c + +$(LIB1)(dfract.o): dfract.c + +$(LIB1)(dfree.o): dfree.c + +$(LIB1)(dfscanf.o): dfscanf.c + +$(LIB1)(dftod.o): dftod.c + +$(LIB1)(dftodr.o): dftodr.c + +$(LIB1)(dint.o): dint.c + +$(LIB1)(diseq.o): diseq.c + +$(LIB1)(disge.o): disge.c + +$(LIB1)(disgt.o): disgt.c + +$(LIB1)(disint.o): disint.c + +$(LIB1)(disle.o): disle.c + +$(LIB1)(dislt.o): dislt.c + +$(LIB1)(disne.o): disne.c + +$(LIB1)(disneg.o): disneg.c + +$(LIB1)(dispos.o): dispos.c + +$(LIB1)(diszero.o): diszero.c + +$(LIB1)(divarr.o): divarr.c + +$(LIB1)(divarrd.o): divarrd.c + +$(LIB1)(divdfd.o): divdfd.c + +$(LIB1)(divid.o): divid.c + +$(LIB1)(divld.o): divld.c + +$(LIB1)(divstr.o): divstr.c + +$(LIB1)(divuid.o): divuid.c + +$(LIB1)(divuld.o): divuld.c + +$(LIB1)(dln.o): dln.c + +$(LIB1)(dlnx.o): dlnx.c + +$(LIB1)(dlog.o): dlog.c + +$(LIB1)(dmag.o): dmag.c + +$(LIB1)(dmant.o): dmant.c + +$(LIB1)(dmax.o): dmax.c + +$(LIB1)(dmbyn.o): dmbyn.c gmsys1.h prologue.h model.h gm.equ + +$(LIB1)(dmbyp10.o): dmbyp10.c prologue.h model.h gm.equ + +$(LIB1)(dmbyp10t.o): dmbyp10t.c prologue.h model.h gm.equ + +$(LIB1)(dmby1.o): dmby1.c gmsys1.h prologue.h model.h gm.equ + +$(LIB1)(dmby1r.o): dmby1r.c gmsys1.h prologue.h model.h gm.equ + +$(LIB1)(dmean.o): dmean.c + +$(LIB1)(dmi.o): dmi.c gmsys1.h prologue.h model.h gm.equ + +$(LIB1)(dmin.o): dmin.c + +$(LIB1)(dmod.o): dmod.c + +$(LIB1)(dmoddf.o): dmoddf.c + +$(LIB1)(dmodi.o): dmodi.c + +$(LIB1)(dmodl.o): dmodl.c + +$(LIB1)(dmodui.o): dmodui.c + +$(LIB1)(dmodul.o): dmodul.c + +$(LIB1)(dmul.o): dmul.c + +$(LIB1)(dmulr.o): dmulr.c + +$(LIB1)(dmult.o): dmult.c + +$(LIB1)(dmux.o): dmux.c + +$(LIB1)(dpct.o): dpct.c + +$(LIB1)(dpdb.o): dpdb.c + +$(LIB1)(dpdbtbl.o): dpdbtbl.c + +$(LIB1)(dpddb.o): dpddb.c + +$(LIB1)(dpddbtbl.o): dpddbtbl.c + +$(LIB1)(dpow.o): dpow.c + +$(LIB1)(dpowi.o): dpowi.c + +$(LIB1)(dpowrat.o): dpowrat.c + +$(LIB1)(dpoxi.o): dpoxi.c + +$(LIB1)(dprec.o): dprec.c + +$(LIB1)(dprintf.o): dprintf.c + +$(LIB1)(dpsl.o): dpsl.c + +$(LIB1)(dpsltbl.o): dpsltbl.c + +$(LIB1)(dpsoy.o): dpsoy.c + +$(LIB1)(dpsoytbl.o): dpsoytbl.c + +$(LIB1)(drad.o): drad.c + +$(LIB1)(droot.o): droot.c + +$(LIB1)(drooti.o): drooti.c + +$(LIB1)(dround.o): dround.c + +$(LIB1)(dscanf.o): dscanf.c + +$(LIB1)(dsetertn.o): dsetertn.c + +$(LIB1)(dsign.o): dsign.c + +$(LIB1)(dsin.o): dsin.c + +$(LIB1)(dsins.o): dsins.c + +$(LIB1)(dsort.o): dsort.c + +$(LIB1)(dsprintf.o): dsprintf.c + +$(LIB1)(dsqrt.o): dsqrt.c + +$(LIB1)(dsqx.o): dsqx.c + +$(LIB1)(dsscanf.o): dsscanf.c + +$(LIB1)(dsub.o): dsub.c + +$(LIB1)(dsux.o): dsux.c + +$(LIB2)(dswap.o): dswap.c + +$(LIB2)(dtan.o): dtan.c + +$(LIB2)(dtoa.o): dtoa.c + +$(LIB2)(dtoac.o): dtoac.c + +$(LIB2)(dtoacr.o): dtoacr.c + +$(LIB2)(dtoaf.o): dtoaf.c + +$(LIB2)(dtoar.o): dtoar.c + +$(LIB2)(dtodc.o): dtodc.c + +$(LIB2)(dtodf.o): dtodf.c + +$(LIB2)(dtoeng.o): dtoeng.c + +$(LIB2)(dtofr.o): dtofr.c + +$(LIB2)(dtoi.o): dtoi.c + +$(LIB2)(dtol.o): dtol.c + +$(LIB2)(dtosci.o): dtosci.c + +$(LIB2)(dtoui.o): dtoui.c + +$(LIB2)(dtoul.o): dtoul.c + +$(LIB2)(dtrunc.o): dtrunc.c + +$(LIB2)(dtrux.o): dtrux.c + +$(LIB2)(dzero.o): dzero.c + +$(LIB2)(dzeroarr.o): dzeroarr.c + +$(LIB2)(d10by5.o): d10by5.c + +$(LIB2)(d10by5t.o): d10by5t.c + +$(LIB2)(efftonom.o): efftonom.c + +$(LIB2)(errname.o): errname.c + +$(LIB2)(funname.o): funname.c + +$(LIB2)(frtod.o): frtod.c + +$(LIB2)(gcmp.o): gcmp.c prologue.h model.h gm.equ + +$(LIB2)(ginc.o): ginc.c prologue.h model.h gm.equ + +$(LIB2)(gmec.o): gmec.c + +$(LIB2)(gmef.o): gmef.c + +$(LIB2)(gmglobal.o): gmglobal.c + +$(LIB2)(gmrs.o): gmrs.c + +$(LIB2)(gmserri.o): gmserri.c + +$(LIB2)(hmi.o): hmi.c gmsys1.h prologue.h model.h gm.equ + +$(LIB2)(intraux.o): intraux.c + +$(LIB2)(irr.o): irr.c + +$(LIB2)(itod.o): itod.c + +$(LIB2)(linest.o): linest.c + +$(LIB2)(lookarr.o): lookarr.c + +$(LIB2)(ltod.o): ltod.c + +$(LIB2)(makid.o): makid.c + +$(LIB2)(makld.o): makld.c + +$(LIB2)(makuid.o): makuid.c + +$(LIB2)(makuld.o): makuld.c + +$(LIB2)(maxarr.o): maxarr.c + +$(LIB2)(median.o): median.c + +$(LIB2)(mgmn.o): mgmn.c gmsys1.h prologue.h model.h gm.equ + +$(LIB2)(minarr.o): minarr.c + +$(LIB2)(mirr.o): mirr.c + +$(LIB2)(mli.o): mli.c gmsys1.h prologue.h model.h gm.equ + +$(LIB2)(mularr.o): mularr.c + +$(LIB2)(mularrd.o): mularrd.c + +$(LIB2)(muldfd.o): muldfd.c + +$(LIB2)(mulid.o): mulid.c + +$(LIB2)(mulld.o): mulld.c + +$(LIB2)(mulstr.o): mulstr.c + +$(LIB2)(muluid.o): muluid.c + +$(LIB2)(mululd.o): mululd.c + +$(LIB2)(mul10.o): mul10.c prologue.h model.h gm.equ + +$(LIB2)(mul10l.o): mul10l.c gmsys1.h prologue.h model.h gm.equ + +$(LIB2)(mul10ad.o): mul10ad.c gmsys1.h prologue.h model.h gm.equ + +$(LIB2)(nfv.o): nfv.c + +$(LIB2)(nomtoeff.o): nomtoeff.c + +$(LIB2)(npv.o): npv.c + +$(LIB2)(padd.o): padd.c + +$(LIB2)(pchange.o): pchange.c + +$(LIB2)(pdiv.o): pdiv.c + +$(LIB2)(pmul.o): pmul.c + +$(LIB2)(pof.o): pof.c + +$(LIB2)(predx.o): predx.c + +$(LIB2)(predy.o): predy.c + +$(LIB2)(ptoy.o): ptoy.c + +$(LIB2)(roundcnt.o): roundcnt.c + +$(LIB2)(psub.o): psub.c + +$(LIB2)(scanfx.o): scanfx.c + +$(LIB2)(sgmn.o): sgmn.c gmsys1.h prologue.h model.h gm.equ + +$(LIB2)(simpaux.o): simpaux.c + +$(LIB2)(simp360.o): simp360.c + +$(LIB2)(simp365.o): simp365.c + +$(LIB2)(smi.o): smi.c gmsys1.h prologue.h model.h gm.equ + +$(LIB2)(spfv.o): spfv.c + +$(LIB2)(sppv.o): sppv.c + +$(LIB2)(sq5to4.o): sq5to4.c + +$(LIB2)(stnddev.o): stnddev.c + +$(LIB2)(subarr.o): subarr.c + +$(LIB2)(subarrd.o): subarrd.c + +$(LIB2)(subdfd.o): subdfd.c + +$(LIB2)(subid.o): subid.c + +$(LIB2)(subld.o): subld.c + +$(LIB2)(substr.o): substr.c + +$(LIB2)(subuid.o): subuid.c + +$(LIB2)(subuld.o): subuld.c + +$(LIB2)(sumarr.o): sumarr.c + +$(LIB2)(sumarrn.o): sumarrn.c + +$(LIB2)(sumarrp.o): sumarrp.c + +$(LIB2)(trunccnt.o): trunccnt.c + +$(LIB2)(uitod.o): uitod.c + +$(LIB2)(ultod.o): ultod.c + +$(LIB2)(usfv.o): usfv.c + +$(LIB2)(uspv.o): uspv.c + +$(LIB2)(wmean.o): wmean.c + +$(LIB2)(ytop.o): ytop.c + diff --git a/gfm/makelsh b/gfm/makelsh new file mode 100755 index 000000000..c7c145669 --- /dev/null +++ b/gfm/makelsh @@ -0,0 +1,507 @@ +CFLAGS=-I$(DEVHOME)/mathlib -DSH_LIB -Otlig -W2 +.c.a: + $CC $CFLAGS $<:.c= + +.asm.a: + masm -Ml $< + +all: objects objects1 objects2 objects3 + mkshlib -s libgfm.sl -t /shlib/libgfm_s -h /lib/libgfm_s.a + +objects : gfmdefs.o adatenly.o adate360.o adate365.o addarr.o addarrd.o adddfd.o addid.o addld.o addstr.o adduid.o adduld.o advpmt.o agmn.o amort.o amorttbl.o atod.o atodr.o bondprc.o bondyld.o comp.o compaux.o compcomp.o compsimp.o dabs.o dacos.o dadd.o dadx.o dalloc.o dalog.o daralloc.o darcpy.o darfree.o dasin.o datan.o datax.o dbd360.o dbd365.o dbdnly.o dchgs.o dchix.o dcmp.o dcos.o dcoss.o dcot.o dcox.o dcpy.o dctod.o ddeg.o ddiv.o ddivpf.o ddivpr.o ddivpt.o ddivr.o ddivt.o ddix.o ddixf.o ddixr.o ddixt.o deltrz.o dexp.o dexx.o dfact.o dfprintf.o dfract.o dfree.o dfscanf.o dftod.o dftodr.o dint.o + +objects1 : diseq.o disge.o disgt.o disint.o disle.o dislt.o disne.o disneg.o dispos.o diszero.o divarr.o divarrd.o divdfd.o divid.o divld.o divstr.o divuid.o divuld.o dln.o dlnx.o dlog.o dmag.o dmant.o dmax.o dmbyn.o dmbyp10.o dmbyp10t.o dmby1.o dmby1r.o dmean.o dmi.o dmin.o dmod.o dmoddf.o dmodi.o dmodl.o dmodui.o dmodul.o dmul.o dmulr.o dmult.o dmux.o dpct.o dpdb.o dpdbtbl.o dpddb.o dpddbtbl.o dpow.o dpowi.o dpowrat.o dpsl.o dpsltbl.o dpsoy.o dpsoytbl.o drad.o droot.o drooti.o dround.o dscanf.o dsetertn.o dsign.o dsin.o dsins.o dsort.o dsprintf.o dsqrt.o dsqx.o dsscanf.o dsub.o dsux.o dswap.o dtan.o dtoa.o dtoac.o dtodc.o dtoacr.o dtoaf.o dtoar.o + +objects2 : dtodf.o dtoeng.o dtofr.o dtoi.o dtol.o dtosci.o dtoui.o dtoul.o dtrunc.o dtrux.o dzero.o dzeroarr.o d10by5.o d10by5t.o efftonom.o errname.o funname.o frtod.o gcmp.o ginc.o gmec.o gmef.o gmglobal.o gmrs.o gmserri.o hmi.o intraux.o irr.o itod.o linest.o lookarr.o ltod.o makid.o makld.o makuid.o makuld.o maxarr.o median.o mgmn.o minarr.o mirr.o mli.o + +objects3 : mularr.o mularrd.o muldfd.o mulid.o mulld.o mulstr.o muluid.o mululd.o mul10.o mul10l.o mul10ad.o nfv.o nomtoeff.o npv.o padd.o pchange.o pdiv.o pmul.o pof.o predx.o predy.o psub.o ptoy.o roundcnt.o scanfx.o sgmn.o simpaux.o simp360.o simp365.o smi.o spfv.o sppv.o sq5to4.o stnddev.o subarr.o subarrd.o subdfd.o subid.o subld.o substr.o subuid.o subuld.o sumarr.o sumarrn.o sumarrp.o trunccnt.o uitod.o ultod.o usfv.o uspv.o wmean.o ytop.o dpoxi.o dprec.o dprintf.o + +gfmdefs.o: gfmdefs.c + +adatenly.o: adatenly.c + +adate360.o: adate360.c + +adate365.o: adate365.c + +addarr.o: addarr.c + +addarrd.o: addarrd.c + +adddfd.o: adddfd.c + +addid.o: addid.c + +addld.o: addld.c + +addstr.o: addstr.c + +adduid.o: adduid.c + +adduld.o: adduld.c + +advpmt.o: advpmt.c + +agmn.o: agmn.asm prologue.h model.h gm.equ + +amort.o: amort.c + +amorttbl.o: amorttbl.c + +atod.o: atod.c + +atodr.o: atodr.c + +bondprc.o: bondprc.c + +bondyld.o: bondyld.c + +comp.o: comp.c + +compaux.o: compaux.c + +compcomp.o: compcomp.c + +compsimp.o: compsimp.c + +dabs.o: dabs.c + +dacos.o: dacos.c + +dadd.o: dadd.c + +dadx.o: dadx.c + +dalloc.o: dalloc.c + +dalog.o: dalog.c + +daralloc.o: daralloc.c + +darcpy.o: darcpy.c + +darfree.o: darfree.c + +dasin.o: dasin.c + +datan.o: datan.c + +datax.o: datax.c + +dbd360.o: dbd360.c + +dbd365.o: dbd365.c + +dbdnly.o: dbdnly.c + +dchgs.o: dchgs.c + +dchix.o: dchix.c + +dcmp.o: dcmp.c + +dcos.o: dcos.c + +dcoss.o: dcoss.c + +dcot.o: dcot.c + +dcox.o: dcox.c + +dcpy.o: dcpy.c + +dctod.o: dctod.c + +ddeg.o: ddeg.c + +ddiv.o: ddiv.c + +ddivpf.o: ddivpf.c + +ddivpr.o: ddivpr.c + +ddivpt.o: ddivpt.c + +ddivr.o: ddivr.c + +ddivt.o: ddivt.c + +ddix.o: ddix.c + +ddixf.o: ddixf.c + +ddixr.o: ddixr.c + +ddixt.o: ddixt.c + +deltrz.o: deltrz.c + +dexp.o: dexp.c + +dexx.o: dexx.c + +dfact.o: dfact.c + +dfprintf.o: dfprintf.c + +dfract.o: dfract.c + +dfree.o: dfree.c + +dfscanf.o: dfscanf.c + +dftod.o: dftod.c + +dftodr.o: dftodr.c + +dint.o: dint.c + +diseq.o: diseq.c + +disge.o: disge.c + +disgt.o: disgt.c + +disint.o: disint.c + +disle.o: disle.c + +dislt.o: dislt.c + +disne.o: disne.c + +disneg.o: disneg.c + +dispos.o: dispos.c + +diszero.o: diszero.c + +divarr.o: divarr.c + +divarrd.o: divarrd.c + +divdfd.o: divdfd.c + +divid.o: divid.c + +divld.o: divld.c + +divstr.o: divstr.c + +divuid.o: divuid.c + +divuld.o: divuld.c + +dln.o: dln.c + +dlnx.o: dlnx.c + +dlog.o: dlog.c + +dmag.o: dmag.c + +dmant.o: dmant.c + +dmax.o: dmax.c + +dmbyn.o: dmbyn.c gmsys1.h prologue.h model.h gm.equ + +dmbyp10.o: dmbyp10.c prologue.h model.h gm.equ + +dmbyp10t.o: dmbyp10t.c prologue.h model.h gm.equ + +dmby1.o: dmby1.c gmsys1.h prologue.h model.h gm.equ + +dmby1r.o: dmby1r.c gmsys1.h prologue.h model.h gm.equ + +dmean.o: dmean.c + +dmi.o: dmi.c gmsys1.h prologue.h model.h gm.equ + +dmin.o: dmin.c + +dmod.o: dmod.c + +dmoddf.o: dmoddf.c + +dmodi.o: dmodi.c + +dmodl.o: dmodl.c + +dmodui.o: dmodui.c + +dmodul.o: dmodul.c + +dmul.o: dmul.c + +dmulr.o: dmulr.c + +dmult.o: dmult.c + +dmux.o: dmux.c + +dpct.o: dpct.c + +dpdb.o: dpdb.c + +dpdbtbl.o: dpdbtbl.c + +dpddb.o: dpddb.c + +dpddbtbl.o: dpddbtbl.c + +dpow.o: dpow.c + +dpowi.o: dpowi.c + +dpowrat.o: dpowrat.c + +dpoxi.o: dpoxi.c + +dprec.o: dprec.c + +dprintf.o: dprintf.c + +dpsl.o: dpsl.c + +dpsltbl.o: dpsltbl.c + +dpsoy.o: dpsoy.c + +dpsoytbl.o: dpsoytbl.c + +drad.o: drad.c + +droot.o: droot.c + +drooti.o: drooti.c + +dround.o: dround.c + +dscanf.o: dscanf.c + +dsetertn.o: dsetertn.c + +dsign.o: dsign.c + +dsin.o: dsin.c + +dsins.o: dsins.c + +dsort.o: dsort.c + +dsprintf.o: dsprintf.c + +dsqrt.o: dsqrt.c + +dsqx.o: dsqx.c + +dsscanf.o: dsscanf.c + +dsub.o: dsub.c + +dsux.o: dsux.c + +dswap.o: dswap.c + +dtan.o: dtan.c + +dtoa.o: dtoa.c + +dtoac.o: dtoac.c + +dtoacr.o: dtoacr.c + +dtoaf.o: dtoaf.c + +dtoar.o: dtoar.c + +dtodc.o: dtodc.c + +dtodf.o: dtodf.c + +dtoeng.o: dtoeng.c + +dtofr.o: dtofr.c + +dtoi.o: dtoi.c + +dtol.o: dtol.c + +dtosci.o: dtosci.c + +dtoui.o: dtoui.c + +dtoul.o: dtoul.c + +dtrunc.o: dtrunc.c + +dtrux.o: dtrux.c + +dzero.o: dzero.c + +dzeroarr.o: dzeroarr.c + +d10by5.o: d10by5.c + +d10by5t.o: d10by5t.c + +efftonom.o: efftonom.c + +errname.o: errname.c + +funname.o: funname.c + +frtod.o: frtod.c + +gcmp.o: gcmp.c prologue.h model.h gm.equ + +ginc.o: ginc.c prologue.h model.h gm.equ + +gmec.o: gmec.c + +gmef.o: gmef.c + +gmglobal.o: gmglobal.c + +gmrs.o: gmrs.c + +gmserri.o: gmserri.c + +hmi.o: hmi.c gmsys1.h prologue.h model.h gm.equ + +intraux.o: intraux.c + +irr.o: irr.c + +itod.o: itod.c + +linest.o: linest.c + +lookarr.o: lookarr.c + +ltod.o: ltod.c + +makid.o: makid.c + +makld.o: makld.c + +makuid.o: makuid.c + +makuld.o: makuld.c + +maxarr.o: maxarr.c + +median.o: median.c + +mgmn.o: mgmn.c gmsys1.h prologue.h model.h gm.equ + +minarr.o: minarr.c + +mirr.o: mirr.c + +mli.o: mli.c gmsys1.h prologue.h model.h gm.equ + +mularr.o: mularr.c + +mularrd.o: mularrd.c + +muldfd.o: muldfd.c + +mulid.o: mulid.c + +mulld.o: mulld.c + +mulstr.o: mulstr.c + +muluid.o: muluid.c + +mululd.o: mululd.c + +mul10.o: mul10.c prologue.h model.h gm.equ + +mul10l.o: mul10l.c gmsys1.h prologue.h model.h gm.equ + +mul10ad.o: mul10ad.c gmsys1.h prologue.h model.h gm.equ + +nfv.o: nfv.c + +nomtoeff.o: nomtoeff.c + +npv.o: npv.c + +padd.o: padd.c + +pchange.o: pchange.c + +pdiv.o: pdiv.c + +pmul.o: pmul.c + +pof.o: pof.c + +predx.o: predx.c + +predy.o: predy.c + +ptoy.o: ptoy.c + +roundcnt.o: roundcnt.c + +psub.o: psub.c + +scanfx.o: scanfx.c + +sgmn.o: sgmn.c gmsys1.h prologue.h model.h gm.equ + +simpaux.o: simpaux.c + +simp360.o: simp360.c + +simp365.o: simp365.c + +smi.o: smi.c gmsys1.h prologue.h model.h gm.equ + +spfv.o: spfv.c + +sppv.o: sppv.c + +sq5to4.o: sq5to4.c + +stnddev.o: stnddev.c + +subarr.o: subarr.c + +subarrd.o: subarrd.c + +subdfd.o: subdfd.c + +subid.o: subid.c + +subld.o: subld.c + +substr.o: substr.c + +subuid.o: subuid.c + +subuld.o: subuld.c + +sumarr.o: sumarr.c + +sumarrn.o: sumarrn.c + +sumarrp.o: sumarrp.c + +trunccnt.o: trunccnt.c + +uitod.o: uitod.c + +ultod.o: ultod.c + +usfv.o: usfv.c + +uspv.o: uspv.c + +wmean.o: wmean.c + +ytop.o: ytop.c diff --git a/gfm/makid.c b/gfm/makid.c new file mode 100755 index 000000000..809cb4d5f --- /dev/null +++ b/gfm/makid.c @@ -0,0 +1,44 @@ +/* DEC *MakeDecimalFromInt( x, l, n) + * + * ARGUMENT + * DEC *x; + * int l; + * int n; + * + * DESCRIPTION + * Converts an int to a DEC with implied decimal 'n'. For example, + * if long = 2345 and n=2, then DEC will have a value = 23.45. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MakeDecimalFromInt( x, l, n) +DEC *x; +int l; +int n; +{ + DEC *t; + _MacStart(GM_MAKID); + + t = MakeDecimalFromLong(x, (long) l, n); + _MacRet(t); +} diff --git a/gfm/makld.c b/gfm/makld.c new file mode 100755 index 000000000..3dd9a85c9 --- /dev/null +++ b/gfm/makld.c @@ -0,0 +1,54 @@ +/* DEC *MakeDecimalFromLong( x, l, n) + * + * ARGUMENT + * DEC *x; + * long l; + * int n; + * + * DESCRIPTION + * Converts a long to a DEC with implied decimal 'n'. For example, + * if long = 2345 and n=2, then DEC will have a value = 23.45. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MakeDecimalFromLong( x, l, n) +DEC *x; +long l; +int n; +{ + _MacStart(GM_MAKLD); + _MacOutVarD(x); + + if((n>GM_MAXID)||(nls.lattr = (l<0) ? 1 : 0; + x->ls.lid = n; + x->ls.lsl[0] = (l<0) ? -l : l; + x->ls.lsl[1] = 0; + x->dc.msd = 0; + + _MacRet(x); +} diff --git a/gfm/makuid.c b/gfm/makuid.c new file mode 100755 index 000000000..27cc49029 --- /dev/null +++ b/gfm/makuid.c @@ -0,0 +1,44 @@ +/* DEC *MakeDecimalFromUns( x, l, n) + * + * ARGUMENT + * DEC *x; + * unsigned l; + * int n; + * + * DESCRIPTION + * Converts an int to a DEC with implied decimal 'n'. For example, + * if long = 2345 and n=2, then DEC will have a value = 23.45. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MakeDecimalFromUns( x, l, n) +DEC *x; +unsigned int l; +int n; +{ + DEC *t; + _MacStart(GM_MAKUID); + + t = MakeDecimalFromLong(x, (long) l, n); + _MacRet(t); +} diff --git a/gfm/makuld.c b/gfm/makuld.c new file mode 100755 index 000000000..001baed63 --- /dev/null +++ b/gfm/makuld.c @@ -0,0 +1,53 @@ +/* DEC *MakeDecimalFromUnsLong( x, l, n) + * + * ARGUMENT + * DEC *x; + * unsigned long l; + * int n; + * + * DESCRIPTION + * Converts unsigned long 'l' to a DEC with implied decimal 'n'. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * The DEC if the conversion is successful, and GM_NULL otherwise. + * + * POSSIBLE ERROR CODES + * + * GM_INVALIDID + * + * AUTHOR + * Jared Levy Feb. 9, 1987 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MakeDecimalFromUnsLong( x, l, n) +DEC *x; +unsigned long l; +int n; + +{ + _MacStart(GM_MAKULD); + _MacOutVarD(x); + if((n>GM_MAXID)||(nls.lattr = 0; + x->ls.lid = n; + x->ls.lsl[0] = l; + x->ls.lsl[1] = 0L; + x->dc.msd = 0; + + _MacRet(x); +} diff --git a/gfm/maxarr.c b/gfm/maxarr.c new file mode 100755 index 000000000..ecf6fe89f --- /dev/null +++ b/gfm/maxarr.c @@ -0,0 +1,77 @@ +/* DEC *FindMaximumDecimalArray(pDst, pSrc, size) + * + * ARGUMENT + * DEC *pSrc[]; + * DEC *pDst; + * int size; + * + * DESCRIPTION + * Given size DEC pointers stored in the array pSrc, finds the maximum + * element and stores that value in pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns GM_NULL on error, otherwise pDst. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_ARGVAL (when size is 0) + * + * AUTHOR + * AA 9-8-87 10:45 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *FindMaximumDecimalArray(pDst, pSrc, size) +DEC *pSrc[]; +DEC *pDst; +int size; +{ + int i,wRetVal,max; + DEC *pm; + + _MacStart(GM_MAXARR); + + _MacOutVarD(pDst); + + if (!pSrc) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + + if (size<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + for (i=0; i +#include +#include "gm.h" +#include "gmsystem.h" + +#ifndef DOS +extern char *calloc(unsigned ,unsigned ); +#endif + +DEC *Median(pDst,pSrc,n) +DEC *pDst; +DEC **pSrc; +int n; +{ + int i; + DEC **tmpa, dsum, *sum=&dsum; + extern void qsort(char *, unsigned, unsigned, int (*)(void)); + + _MacStart(GM_MEDIAN); + + if (!pSrc) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + + if (n<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + for (i=0; i + + dseg _gm + endds + + pseg gmath +; +; +; if large memory model then: +; +; parm1_ = ptr to multiplier +; parm3_ = ptr to multiplicand +; parm5_ = destination segment ptr } pointer to unsigned[10] +; destination offset ptr } destination +; parm7_ = # of 16-bit int's in multiplier +; parm8_ = # of 16-bit int's in multiplicand +; parm9_ = temp for current multiplier +; +; for if small model then +; parm1_ = ptr to multiplier +; parm2_ = ptr to multiplicand +; parm3_ = ptr to unsigned[10] dst +; parm4_ = # of 16-bit int's in MULTIPLIER (a1,...,an) +; parm5_ = # of 16-bit int's in MULTIPLICAND(b1,...,bn) +; parm6_ = temp for current multiplier +; +; +; Then set up and do the first set of mults. Note that the # of +; 'bigloop' iterations correspond to the number of 16-bit digits +; in the multiplier and the 'mlp' loop iterations correspond to the +; # ints in the multiplicand. [these line up if you set tab=5]. +; Algorithm(32-bitx32-bit): +; b2 b1 +; a2 a1 +; __________ +; +;| first p1h p1l +;|iteration p2h p2l +;|2nd p3h p3l +;|iter p4h p4l +; ____________________________________ +; c4 c3 c2 c1 +; +;or---> Algorithm(64-bitx32-bit): +; b4 b3 b2 b1 +; a2 a1 +; __________________ +;| first p1h p1l +;|iteration p2h p2l +;| p3h p3l +;| p4h p4l +;---- +;| p5h p5l +;| 2nd p6h p6l +;|iter p7h p7l +;| p8h p8l +;----- +;______________________________________ +; 0 0 c6 c5 c4 c3 c2 c1 +; +;or---> Algorithm(64-bitx64-bit): +; b4 b3 b2 b1 +; a4 a3 a2 a1 +; __________________ +;| first p1h p1l +;|iteration p2h p2l +;| p3h p3l +;| p4h p4l +;---- +;| p5h p5l +;| 2nd p6h p6l +;|iter p7h p7l +;| p8h p8l +;----- +;| third p1h p1l +;|iteration p2h p2l +;| p3h p3l +;| p4h p4l +;---- +;| p5h p5l +;| 4th p6h p6l +;|iter p7h p7l +;| p8h p8l +;----- +;| fifth p9h p9l +;|iteration p10h p10l +;| p11h p11l +;| p12h p12l +;---- +;| 6th p13h p13l +;| p14h p14l +;| p15h p15l +;|p16h p16l +;----- +;_________________________________________________________________ +; c8 c7 c6 c5 c4 c3 c2 c1 +; +; As each multiply is done, the partial product is added to +; the destination 'dst' +; +; +; + cproc _MulUnsArrByUnsArr,,_mgmn + +if _LDATA + push ds + push es + mov ax,parm7_ + cmp ax,parm8_ ; see which is larger + jle nochg ; m +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + +void _MulUnsArrByUnsArr(src1, src2, dst, m, n, tmp1) +unsigned SHORT src1[], src2[], dst[]; +int n,m,tmp1; +{ + int i,j; + unsigned long apdst[10]; + unsigned long pdst,maxunsint; + + tmp1=0; +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(double)BITSPERUI)-1; +#endif + + for(i=0;i<10;i++) + { + apdst[i]=0; + } + + for(i=0;imaxunsint) + { + apdst[i+j+1]+=(unsigned long)(pdst>>BITSPERUI); + apdst[i+j]+=(unsigned long)(pdst&maxunsint); + } + else + { + apdst[i+j]+=(unsigned long)pdst; + } + } + } + for(i=0;i<10;i++) + { + if (apdst[i]>maxunsint) + { + apdst[i+1]+=(unsigned long)(apdst[i]>>BITSPERUI); + apdst[i]=(unsigned long)(apdst[i]&maxunsint); + } + } + for(i=0;i<10;i++) + { + dst[i]=(unsigned SHORT)apdst[i]; + } +} + diff --git a/gfm/minarr.c b/gfm/minarr.c new file mode 100755 index 000000000..56ea4b43e --- /dev/null +++ b/gfm/minarr.c @@ -0,0 +1,74 @@ +/* DEC *FindMinimumDecimalArray(pDst, pSrc, size) + * + * ARGUMENT + * DEC *pSrc[]; + * DEC *pDst; + * int size; + * + * DESCRIPTION + * Given size DEC pointers stored in the array pSrc, finds the minimum + * element and stores that value in pDst. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns GM_NULL on error, otherwise pDst. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_ARGVAL (when size is 0) + * + * AUTHOR + * AA 9-8-87 10:45 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *FindMinimumDecimalArray(pDst, pSrc, size) +DEC *pSrc[]; +DEC *pDst; +int size; +{ + int i,wRetVal,min; + DEC *pm; + + _MacStart(GM_MINARR); + if(!pSrc||!pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + + if (size<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + for (i=0; i0) + min=i; + i++; + } + + pm = pSrc[min]; + _MacDCopy(pDst,pm); + _MacRet(pDst); +} diff --git a/gfm/mirr.c b/gfm/mirr.c new file mode 100755 index 000000000..cad6b8ab7 --- /dev/null +++ b/gfm/mirr.c @@ -0,0 +1,137 @@ +/* DEC *ModifiedIRR(irr, flows, nflow, intr, safe) + * + * ARGUMENT + * DEC *irr, **flows, *intr, *safe; + * int nflow; + * + * DESCRIPTION + * Calculates the modified int. rate of return of a series of cash flows. + * The nflow cash flows in the array flows are invested at interest + * rate intr for positive cash flows and borrows at interest rate safe + * for negative cash flows. + * The modified internal rate of return is calculated and stored in irr. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * irr if successful, otherwise GM_NULL. + * + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *ModifiedIRR(irr, flows, nflow, intr, safe) +DEC *irr, **flows, *intr, *safe; +int nflow; +{ + int i; + mbool wfNeg, wfPos; + DEC dtemp, *temp=&dtemp, dooopi, *ooopi=&dooopi; + DEC dpow, *pow=&dpow, dopi, *opi=&dopi; + DEC dnpvn, *npvn=&dnpvn, dnfvp, *nfvp=&dnfvp; + DEC *p; + + _MacStart(GM_MIRR); + + if (nflow<2) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + _MacInVarD(intr); + _MacInVarD(safe); + if (!flows) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + _MacOutVarD(irr); + /* check for null pointers, at least one pos & neg cash flow */ + wfPos=FALSE; + wfNeg=FALSE; + for (i=0;idc.id+=2; + (void) _AddDec80Bit(temp, temp, &decOne); + (void) _DivDec80Bit(ooopi, &decOne, temp); + + _MacDCopy(pow, (&decOne)); + + for (i=0;idc.id+=2; + (void) _AddDec80Bit(opi, temp, &decOne); + + _MacDCopy(pow, (&decOne)); + + for (i=nflow-1;i>=0;i--) { + if (_MacIsDecP(flows[i])) { + (void) _MulDec80Bit(temp, flows[i], pow); + (void) _AddDec80Bit(nfvp, nfvp, temp); + } + (void) _MulDec80Bit(pow, pow, opi); + } + +/* calculate modified internal rate of return */ + _MacDChgs(npvn); + (void) _DivDec80Bit(temp, nfvp, npvn); + (void) _LnDec80Bit(temp, temp); + (void) ConvLongToDecimal(pow, (long) (nflow-1)); + (void) _DivDec80Bit(temp, temp, pow); + (void) _ExpDec80Bit(temp, temp); + (void) _SubDec80Bit(temp, temp, &decOne); + if (temp->dc.id>=2) + temp->dc.id -=2; + else { + ConvLongToDecimal(pow, 100L); + (void) _MulDec80Bit(temp, temp, pow); + } + + (void) _Sq5UnsTo4Uns(temp); + _MacDCopy(irr,temp); + _MacRet(irr); +} diff --git a/gfm/mli.asm b/gfm/mli.asm new file mode 100755 index 000000000..234e4b5bd --- /dev/null +++ b/gfm/mli.asm @@ -0,0 +1,153 @@ + ; void _MulUnsArr(src1,dst,num,n) + ; + ; ARGUMENT + ; unsigned *src1[],*dst,num; + ; int n; + ; + ; DESCRIPTION + ; Multiplies the number src1(taken as one number of 'n' 16-bit int's) + ; by 'num' and puts the result in dst. Note that it is assumed that + ; the caller has made sure there are enough int's to hold the result. + ; WE DON'T CHECK FOR OVERFLOW. + ; + ; SIDE EFFECTS + ; None. Can't have more that 10 ints to multiply. + ; + ; RETURNS + ; None. + ; + ; AUTHOR + ; Andy Anderson 31-JAN-1987 15:10 + ; Copyright (C) 1987-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; aa 09-JUL-87 80-bit + ; + + include model.h + include prologue.h + include gm.equ + + + ReferVar wrgGMPartProd, + + dseg _gm + endds + + pseg gmath +; +; +; if large memory model then: +; +; parm1_ = ptr to source 1 (segment and offset) +; parm3_ = ptr to destination (segment and offset) +; parm5_ = 16-bit multiplier +; parm6_ = number of ints in src1 (multiplicand) +; +; for if small model then +; parm1_ = ptr to source1 +; parm2_ = ptr to destination +; parm3_ = 16-bit multiplier +; parm4_ = number of ints in src1 (multiplicand) +; +; + + cproc _MulUnsArr,,_mli + +if _LDATA + push es + les si,parm1_ ; ptr to src1 + mov cx,parm6_ ; number of digits in multiplicand +else + mov si,parm1_ ; ditto for small model + mov cx,parm4_ ; number of digits in multiplicand +endif +ifdef DSNOTHING + mov ax,seg wrgGMPartProd + mov ds,ax + lea di,wrgGMPartProd +else + lea di,wrgGMPartProd ; ptr to partial prod array +endif + xor ax,ax ; clear flags + xor bx,bx ; clear offset + +lp: +if _LDATA + mov ax,es:[bx+si] ; starting at lsd, get next highest + mul Word Ptr parm5_ ; result: dx(high) ax(low) +else + mov ax,[bx+si] ; starting at lsd, get next highest + mul Word Ptr parm3_ ; result: dx(high) ax(low) +endif + mov [bx+di],ax ; save partial products + mov [bx+di+2],dx + add di,2 + add bx,2 + loop lp + +; Now that we're done with mult's, do the partial +; product adds and put them in dest. +; +ifdef DSNOTHING + mov ax,seg wrgGMPartProd + mov ds,ax + lea si,wrgGMPartProd +else + lea si,wrgGMPartProd ; ptr to partial prod array +endif + +if _LDATA + les di,parm3_ ; ptr to destination + mov cx,parm6_ ; restore count for # of mult's +else + mov di,parm2_ + mov cx,parm4_ ; restore count for # of mult's +endif + dec cx ; one less than the # of mult's + xor ax,ax + mov bx,0002h + +; +; The first low-order partial product doesn't need to be +; added, just moved. +; + mov ax,[si] ; 1st 16-bit product just moves +if _LDATA + mov es:[di],ax +else + mov [di],ax +endif + cmp cx,0000h + je lastdig ; if we did only one mult +movlp: + mov ax,0000h + adc ax,[bx+si] + adc ax,[bx+si+2] +if _LDATA + mov es:[bx+di],ax +else + mov [bx+di],ax +endif + inc bx + inc bx + inc si + inc si + loop movlp +; +; Now just move in last digit from mult +lastdig: + mov ax,0000h + adc ax,[bx+si] + cmp bx,20 ; will throw away last word of + jge exit ; carry if more than 10 words max +if _LDATA + mov es:[bx+di],ax +exit: pop es +else + mov [bx+di],ax +exit: +endif + cproce + endps + END diff --git a/gfm/mli.c b/gfm/mli.c new file mode 100755 index 000000000..9dfaae10b --- /dev/null +++ b/gfm/mli.c @@ -0,0 +1,68 @@ +/* void _MulUnsArr(src1,dst,num,n) + * + * ARGUMENT + * unsigned *src1, *dst, num; + * unsigned n; + * + * DESCRIPTION + * Multiplies the number 'a' (of 'n' 16-bits ints) by num and places + * the result in dst. We assume that the caller has made sure there are + * enough ints to hold the result. We don't check for overflow!!!. + * + * SIDE EFFECTS + * Can't have more than 10 ints to multiply. + * + * RETURNS + * None. + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + +void _MulUnsArr(src1, dst, num, n) +unsigned SHORT src1[], dst[], num; +int n; +{ + int i; + unsigned long pdst[10],maxunsint; + unsigned SHORT carry; + +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1; +#endif + carry=0; + + for (i=0;imaxunsint) + { + carry=(unsigned SHORT)(pdst[i]>>BITSPERUI); + dst[i]=(unsigned SHORT)(pdst[i]&maxunsint); + } + else + { + carry=0; + dst[i]=(unsigned SHORT)pdst[i]; + } + } +} diff --git a/gfm/model.h b/gfm/model.h new file mode 100755 index 000000000..86c0bdea8 --- /dev/null +++ b/gfm/model.h @@ -0,0 +1,6 @@ +; MODEL.H - Copyright (C) 1989 Greenleaf Software Inc. +; Supports Microsoft C v5.10 +_LCODE equ 1 +_LDATA equ 1 +_HUGE equ 0 +_MSC equ 5 diff --git a/gfm/mul10.asm b/gfm/mul10.asm new file mode 100755 index 000000000..c718cba69 --- /dev/null +++ b/gfm/mul10.asm @@ -0,0 +1,149 @@ +; int _MulUnsArrByPwrOf10(pa,n,w); +; +; +; ARGUMENTS +; unsigned *pa[] points to pa[10], a w word number +; (both input and output) +; int n Number of power of ten multiplier 0..47 +; int w Number of words (digits) +; +; DESCRIPTION +; Multiplies the input in the pa[] array (a w word number) +; by 10^n where 0<=n<=47. +; +; The application is in divide routines for adjusting the result. +; +; SIDE EFFECTS +; The value in the source array is unchanged on overflow. +; +; RETURNS +; GM_OVERFLOW if there is an overflow, otherwise GM_SUCCESS. +; +; +; AUTHOR +; Don Killen 14-Jun-1988 15:19:03 +; Copyright (C) 1988-90 Greenleaf Software Inc. All Rights Reserved. +; + include model.h + include prologue.h + include gm.equ + + dseg mul10 +power dw 1 dup(?) ; power of ten to do +numnz dw 1 dup(?) ; number of nonzero digits +totdig dw 1 dup(?) ; total number of digits +tmpdig dw 1 dup(?) ; temp. copy of number of non-zero digits +p10 dw 1,10d,100d,1000d,10000d ; powers of 10 + endds + + pseg mul10 + cproc _MulUnsArrByPwrOf10,,_mul10 + if _LDATA + push es + les di,parm1_ ; get pointer to source/destination + mov dx,parm3_ ; get power of 10 + mov bx,parm4_ ; get number of words + else + mov di,parm1_ ; get pointer to source/destination + mov ax,ds + mov es,ax + mov dx,parm2_ ; get power of 10 + mov bx,parm3_ ; get number of words + endif + + mov si, di ; copy array location (for future recall) + mov totdig, bx ; store number of digits +; dec power + +; Find highest nonzero digit +; (so time isn't wasted multiplying zeroes) + sal bx, 1 ; want digits in words +lpnz: dec bx ; decrease word by 1 (2 bytes) + dec bx + jns nxtlin + jmp success ; negative bx => source is 0 => done +nxtlin: mov ax,0 + cmp ax,word ptr es:[di+bx] + je lpnz +; + shr bx,1 ; want number of words, not bytes + inc bx ; number of digits one more than digit number + mov numnz,bx ; store # of non-zero digits + mov tmpdig,bx ; store again (for counter) + +; multiplies by 10000 for all multiplications but last to run faster +; find correct number to mul by & decrease power (# of remaining muls) +bigloop: + cmp dx, 4 ; check if multiplying by power greater than 4 + jge pg4 + mov ax, 0 ; if so, no subsequent muls needed + mov power, ax + sal dx, 1 ; get power of 10 + mov bx, dx + mov bx, p10[bx] + jmp short bmul +pg4: + sub dx, 4 ; subtract 4 from remaining powers of 10 + mov power, dx + mov bx, 10000d + +; begin multiplication, handling first digit specially +bmul: + mov ax, word ptr es:[di] ; get first digit + mul bx ; multiply digit + mov word ptr es:[di], ax ; store lower digit + dec tmpdig ; decrease digit counter + clc + jz onedig ; only one digit + +; now multiply remaining digits +loop1: + mov cx, dx ; save high word + inc di ; go to next digit + inc di + mov ax, word ptr es:[di] ; get next digit + pushf ; save carry flag + mul bx ; multiply digit + popf ; retrieve carry flag + adc ax, cx ; add previous high word + mov word ptr es:[di], ax ; store lower digit + dec tmpdig ; check if any more digs to mul + jnz loop1 + +; handle carry into additional digit (contained in dx) +onedig: + adc dx, 0 ; add carry flag + jz nomore ; if dx=0, no more nonzero digits + +; if additional digit, increment digit # & store digit + mov ax, numnz ; get old # of digits + cmp ax, totdig ; check for overflow + jge overflow ; if equal, overflow occured + inc numnz ; one more digit now + inc di ; digit goes in next word + inc di + mov word ptr es:[di], dx ; store high digit + +nomore: + mov dx, power ; check if through + cmp dx, 0 + jz success + mov ax, numnz ; get # of digits + mov tmpdig,ax ; copy # of non-zero digits + mov di, si ; copy pointer + jmp short bigloop + +overflow: + mov ax,GM_OVERFLOW ; indicate error + jmp short through + +success: + mov ax,GM_SUCCESS +through: + if _LDATA + pop es + endif + cproce + + endps + end diff --git a/gfm/mul10.c b/gfm/mul10.c new file mode 100755 index 000000000..e4bdfda77 --- /dev/null +++ b/gfm/mul10.c @@ -0,0 +1,104 @@ +/* int _MulUnsArrByPwrOf10(pa,n,w) + * + * ARGUMENT + * unsigned pa[]; + * int n; power of 10 to multiply by + * int w; number of digits + * + * DESCRIPTION + * Multiplies the pa[] array by 10^n (0 +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + +int Multiply(sr,num,m) +unsigned SHORT sr[],num; +int m; +{ + int i; + unsigned long pdst[10],maxunsint; + unsigned SHORT carry; + +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1; +#endif + carry=0; + + for (i=0;imaxunsint) + { + carry=(unsigned SHORT)(pdst[i]>>BITSPERUI); + sr[i]=(unsigned SHORT)(pdst[i]&maxunsint); + } + else + { + carry=0; + sr[i]=(unsigned SHORT)pdst[i]; + } + } + return( (carry)? GM_OVERFLOW : GM_SUCCESS ); +} + + +int _MulUnsArrByPwrOf10(pa,n,w) +unsigned SHORT pa[]; +int n,w; +{ + +int ppdf,k,i; + + k=GM_SUCCESS; + + if (n>47) + { + k=GM_OVERFLOW; + } + + while ((n>4)&&(k==GM_SUCCESS)) + { + k=Multiply(pa,10000,w); + n-=4; + } + + if (k!=GM_OVERFLOW) + { +#ifdef SH_LIB + ppdf=1; + for (i=1;i<=n;i++) ppdf*=10; +#else + ppdf=(int)pow(10.,(double)n); +#endif + k=Multiply(pa,ppdf,w); + } + + return(k); + +} diff --git a/gfm/mul10ad.asm b/gfm/mul10ad.asm new file mode 100755 index 000000000..a7c473226 --- /dev/null +++ b/gfm/mul10ad.asm @@ -0,0 +1,322 @@ + ; int _MulUnsArrP10AndAddInt(pa,c); + ; + ; ARGUMENT + ; unsigned *pa points to a pa[5], or 80-bit number + ; int c # to add after mult by 10 + ; + ; DESCRIPTION + ; multiplies the number (<=80-bits) in the int array by decimal 10 + ; and adds 'c' to it. Used in the divide routines for adjusting + ; the result. + ; + ; SIDE EFFECTS + ; The value in the source array is indeterminate on overflow. + ; + ; RETURNS + ; Returns GM_OVERFLOW on overflow, otherwise GM_SUCCESS. + ; + ; AUTHOR + ; Andy Anderson 27-JUL-87 80-bit + ; Copyright (C) 1987-90 Greenleaf Software Inc. All Rights Reserved. + ; + ; MODIFICATIONS + ; + ; + .SFCOND + + include model.h + include prologue.h + include gm.equ + + ReferVar wGMTemp1, + ReferVar wrgGMPartProd, + + dseg _gm + endds + + pseg gmath +; +; if large memory model then: +; +; parm1_ = ptr to source 1 +; parm3_ = number to add to a*10 +; +; for if small model then +; parm1_ = ptr to source1 +; parm2_ = number to add to result of a * 10 +; + + cproc _MulUnsArrP10AndAddInt,,_mul10ad + +if _LDATA + push ds + push es + lds si,parm1_ ; ptr to dst (=src) +else + mov si,parm1_ +endif +; +; to multiply by 10, we mult by 4 using 2 shifts, add the +; original number making 5 times the original, then multiply +; that by 2 giving a multiplication by 10. This is many times +; FASTER than the mul instruction!!! +; + + mov ax,[si+8] ; get msd for possible overflow + cmp ax,3000h ; overflow if sign sets during the + jl nxt ; first shift set + jmp overf +nxt: cmp ax,0bffh ; if < this, no overflow possible + jl ct ; no possibility of overflow + jmp tstover ; further testing needed +ct: xor ax,ax ; start clear for test + mov bx,8 ; offset to last int + mov cx,5 ; max number of ints in 80-bit value +numints: + or ax,[bx+si] ; see if upper 80 bits are set + jnz gotdig ; and stop when first one seen + dec bx + dec bx + loop numints ; if we find all of them zero +if _LDATA + mov ax,parm3_ +else + mov ax,parm2_ +endif + mov [si],ax ; just put it in low-order word + jmp gexit +gotdig: +ifdef DSNOTHING + push ds + mov ax, seg wGMTemp1 + mov ds,ax + mov wGMTemp1,cx ; save # of digits in source + pop ds +else + mov wGMTemp1,cx ; save # of digits in source +endif +; +; then shift the number of ints figured for each loop +; +ifdef DSNOTHING + mov ax, seg wrgGMPartProd + mov es,ax +endif + lea di,wrgGMPartProd ; ptr to work area + + xor bx,bx + mov dx,bx +shlp: + mov ax,[bx+si] ; do 16-bits at a time + clc + rcl dx,1 ; dummy first time thru + rcl ax,1 ; multiply by 2 + rcl dx,1 ; save carry in dh (d1-d0) + rcl ax,1 ; now original * 4 + rcl dx,1 ; and dx has shifted out bits +ifdef DSNOTHING + mov es:[bx+di],ax ; store temp result +else + mov [bx+di],ax ; store temp result +endif + ror dx,1 + ror dx,1 + inc bx + inc bx + loop shlp +; +; if we have bits shifted out into dx left over, then +; we have gained 1 int. This is overflow if we were already +; doing 5 int's! +; + + or dx,0000h ; was max size number, if dx!=0 + jz addin ; no bits shifted into carry +ifdef DSNOTHING + push ds + mov ax,seg wGMTemp1 + mov ds,ax + inc wGMTemp1 ; otherwise, one more int in number + pop ds +else + inc wGMTemp1 ; otherwise, one more int in number +endif + rol dx,1 ; bits to low-order of next msd + rol dx,1 ; in lifo order +ifdef DSNOTHING + mov es:[bx+di],dx +else + mov [bx+di],dx +endif +; +; Then add the original for sum of 5 X original +; +addin: xor bx,bx + mov dx,bx +ifdef DSNOTHING + push ds + mov ax, seg wGMTemp1 + mov ds,ax + mov cx,wGMTemp1 ; k int's in new number + pop ds +else + mov cx,wGMTemp1 ; k int's in new number +endif + clc + +if _LDATA + les di,parm1_ +else + mov di,parm1_ +endif +ifdef DSNOTHING + mov ds,ax ; scrap old DS, get global one +endif + lea si,wrgGMPartProd + +addlp: +if _LDATA + mov ax,[bx+si] ; do 16-bits at a time + adc es:[bx+di],ax +else + mov ax,[bx+si] ; do 16-bits at a time + adc [bx+di],ax +endif + inc bx + inc bx + loop addlp + +; stop as soon as we get an overflow + rcl dx,1 ; save possible overflow + or dx,0000h ; see if bits left over + jz finshft ; no possible overflow or increase + inc wGMTemp1 +if _LDATA + add es:[bx+di],dx +else + add [bx+di],dx +endif + jno finshft ; if sign-bit or carry didn't set: continue + xor dx,dx + inc dx +if _LDATA + mov es:[bx+di+2],dx +else + mov [bx+di+2],dx +endif + inc wGMTemp1 ; increase number of digits in dst + +finshft: + xor bx,bx + mov dx,bx + mov cx,wGMTemp1 ; number of int's to shift + +if _LDATA + lds si,parm1_ +else + mov si,parm1_ +endif +shlp3: + rcl Word Ptr [bx+si],1 ; multiply by 2= times 10 + inc bx + inc bx + loop shlp3 + +; +; high-order bit of int 10 can't be set either +; + rcl dx,1 ; save carry bit + or dx,0000h ; was max size number, if dx!=0 + jz cout ; no bits shifted into carry +ifdef DSNOTHING + push ds + mov ax,seg wGMTemp1 + mov ds,ax + inc wGMTemp1 ; otherwise, one more int in number + cmp wGMTemp1,5 ; if working with 5-int number + pop ds +else + inc wGMTemp1 ; otherwise, one more int in number + cmp wGMTemp1,5 ; if working with 5-int number +endif + jg overf ;overflow: too many digits + + mov [bx+si],dx + +; +; If no overflow, see if we have mult'd # times requested +; +cout: + test [si+8],8000h ; see if high-order word set sign + jnz overf + + xor bx,bx ; clear flags + mov dx,bx +ifdef DSNOTHING + push ds ; save parm1's DS and switch + mov ax,seg wGMTemp1 + mov ds,ax ; to global's DS + mov cx,wGMTemp1 + pop ds ; then back to parm's DS +else + mov cx,wGMTemp1 +endif + +if _LDATA + mov ax, Word Ptr parm3_ +else + mov ax, Word Ptr parm2_ ; get addend +endif +aloop: + adc [bx+si],ax + mov ax,dx + inc bx + inc bx + loop aloop + + rcl dx,1 ; save carry bit + or dx,0000h ; was max size number, if dx!=0 + jz nout ; no bits shifted into carry +ifdef DSNOTHING + push ds ; save parm1's DS and switch + mov ax, seg wGMTemp1 + mov ds,ax ; to global's DS + inc wGMTemp1 ; otherwise, one more int in number + cmp wGMTemp1,5 ; if working with 5-int number + pop ds +else + inc wGMTemp1 ; otherwise, one more int in number + cmp wGMTemp1,5 ; if working with 5-int number +endif + jg overf ;overflow: too many digits + + mov [bx+si],dx + +; +; If no overflow, see if we have mult'd # times requested +; +nout: + test [si+8],8000h ; see if high-order word set sign + jnz overf +gexit: + mov ax,GM_SUCCESS +exit: +if _LDATA + pop es + pop ds +endif + cproce +overf: + mov ax,GM_OVERFLOW ; here only on overflow + jmp short exit +; +; if the msd > 0ccch, or if = 0ccch and the high-order hex +; digit of msd -1 > hex c then overflow will occur, otherwise +; it won't +; +tstover: + cmp ax,0ccch ; overflow if sign sets during the + jg overf + jmp ct ; no overflow possible + endps + END diff --git a/gfm/mul10ad.c b/gfm/mul10ad.c new file mode 100755 index 000000000..b92b5fae0 --- /dev/null +++ b/gfm/mul10ad.c @@ -0,0 +1,132 @@ +/* int _MulUnsArrP10AndAddInt(pa,c) + * + * ARGUMENT + * unsigned pa[]; + * int c; # to add after mult by 10 + * + * DESCRIPTION + * Multiplies the number (<=80bits) in the int array by decimal 10 + * and adds 'c' to it. Used in the divide routines for adjusting, + * + * SIDE EFFECTS + * The value of pa is unchanged on overflow. + * + * RETURNS + * GM_SUCCES if no overflow, otherwise GM_OVERFLOW + * + * AUTHOR + * Brugnoli Giugno 1992 + * + * MODIFICATIONS + * + */ + +#include +#include +#include "gm.h" +#include "gmsystem.h" + +extern double pow(double, double); + +int Mltply(sr,num,m) +unsigned SHORT sr[],num; +int m; +{ + int i; + unsigned long pdst[10],maxunsint; + unsigned SHORT carry; + +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1; +#endif + carry=0; + + for (i=0;imaxunsint) + { + carry=(unsigned SHORT)(pdst[i]>>BITSPERUI); + sr[i]=(unsigned SHORT)(pdst[i]&maxunsint); + } + else + { + carry=0; + sr[i]=(unsigned SHORT)pdst[i]; + } + } + return( ((carry)||(sr[m-1]>>(BITSPERUI-1)))? GM_OVERFLOW : GM_SUCCESS ); +} + + +int _MulUnsArrP10AndAddInt(pa,c) +unsigned SHORT pa[]; +int c; +{ + +int ppdf,k,i; +unsigned long maxunsint,pdst,carry; +unsigned SHORT dst[10]; + + k=GM_SUCCESS; +#ifdef SH_LIB + maxunsint=1; + for (i=1;i<=BITSPERUI;i++) maxunsint*=2; + maxunsint--; +#else + maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1; +#endif + ppdf=10; + for (i=0;i<=9;i++) + { + dst[i]=(i<5?pa[i]:0); + } + k=Mltply(dst,ppdf,5); + i=0; + carry=c; + + if (k!=GM_OVERFLOW) + { + do + { + pdst=(long)dst[i]+(long)carry; + if (pdst>maxunsint) + { + carry=(pdst>>BITSPERUI); + dst[i]=(unsigned SHORT)(pdst&maxunsint); + } + else + { + dst[i]=(unsigned SHORT)pdst; + carry=0; + } + i++; + } + while (carry); + } + + if (i>5) + { + k=GM_OVERFLOW; + } + + if (!k) + { + for (i=0;i<5;i++) + { + pa[i]=dst[i]; + } + } + + return(k); + +} diff --git a/gfm/mul10l.asm b/gfm/mul10l.asm new file mode 100755 index 000000000..6b54a74e9 --- /dev/null +++ b/gfm/mul10l.asm @@ -0,0 +1,189 @@ +; int _MulUnsArrByPwrOf10Limited(pa, n, dig); +; +; +; ARGUMENTS +; unsigned *pa[] points to pa[10], a 160 bit number +; (both input and output) +; int n Number of power of ten multiplier 0..19 +; int dig Number of digits to multiply +; +; DESCRIPTION +; Multiplies the input in the pa[] array (a 160-bit binary number) +; by 10^n where 0<=n<=19. +; If multiplication overflows, multiplies by largest power of 10 +; which doesn't overflow and returns that power of ten. +; The application is in addition when lining up decimal points. +; +; SIDE EFFECTS +; None. (always succeeds) +; +; RETURNS +; Power of ten multiplied by, always <= n. +; +; +; AUTHOR +; Don Killen 14-Jun-1988 15:19:03 + ; Copyright (C) 1988-90 Greenleaf Software Inc. All Rights Reserved. +; + include model.h + include prologue.h + include gm.equ + + dseg mul10l +power dw 1 dup(?) ; power of ten to do +numdig dw 1 dup(?) ; number of nonzero digits +work dw 12 dup (?) ; intermediate result array +hiword dw 1 dup(?) ; byte # of highest word + endds + + pseg mul10l + cproc _MulUnsArrByPwrOf10Limited,,_mul10l + if _LDATA + push es + les di,parm1_ ; get pointer to source/destination + mov ax,parm3_ ; get power of 10 + mov bx,parm4_ ; get number of digits + else + mov di,parm1_ ; get pointer to source/destination + mov ax,ds + mov es,ax + mov ax,parm2_ ; get power of 10 + mov bx,parm3_ ; get number of digits + endif + + mov numdig,bx ; store the number of digits + mov power,ax ; store power of 10 + shl bx, 1 ; bytes rather than words + mov dx, bx + dec dx ; highest byte # is two less than # of bytes + dec dx + mov hiword, dx ; store location of highest word + +; +; Strategy is to multiply by shifting left all 160 bits. +; +; a) Move (parm1) -> work array +; b) shift left work array twice, multiplying by 4 +; c) Add (parm1) <= (parm1)+work, multiplying by 5 +; d) Shift (parm1) left once, multiplying by 10 +; e) Test for overflow (carry out of MSW) each step (jmp to error) +; f) If no error, decrement power & loop to (a) if nonzero. +; g) When power has been decremented to 0, you're done! +; + +; +; Top of main loop, repeat from here 'power' times. +; +lp0: ; top of major loop. +; +; Transfer the source to the work array. Work from msd down to lsd +; + if _LDATA + les di,parm1_ + else + mov di,parm1_ + endif + + mov ax, 3276d ; if high word >= 3276, + mov bx, hiword ; can't multiply any more + cmp ax, word ptr es:[di+bx] + jg canmul ; can multiply + +if _LDATA ; No more mul's possible + mov ax, parm3_ ; From total multiplications, +else + mov ax, parm2_ +endif + sub ax, power ; Subtract remaining mul's + jmp short overflow ; to return number of mul's + +canmul: + mov si,0 ; move msd first + mov cx,numdig +lp2: mov ax,word ptr es:[di] ; load source word + mov word ptr work[si],ax ; store in 'work' + inc si + inc si + inc di + inc di + loop lp2 ; til done. +; +; Shift the work array left two bits. +; + mov cx,numdig ; loop count + mov si,0 ; index into work array + clc +lp4: rcl word ptr work[si],1 ; rotate with carry + inc si + inc si + loop lp4 ; complete 1st shift (x2) + + mov cx,numdig + mov si,0 + clc +lp5: rcl word ptr work[si],1 ; rotate with carry + inc si + inc si + loop lp5 ; complete 2nd shift (x4) +; +; So far, work=pa*4. +; +; Add pa=pa+work, making pa=pa*5 +; + if _LDATA + les di,parm1_ ; get pointer to source/destination + else + mov di,parm1_ ; get pointer to source/destination + endif + + mov cx,numdig + mov si,0 + clc +lp6: mov ax,word ptr work[si] + adc word ptr es:[di],ax + inc di + inc di + inc si + inc si + loop lp6 ; Added orig array to 4x: (x5) +; +; +; At this point, pa=pa*5. Now shift it left making pa=pa*10 +; + if _LDATA + les di,parm1_ + else + mov di,parm1_ + endif + mov cx,numdig + clc +lp7: rcl word ptr es:[di],1 ; rotate left to shift with carry. + inc di + inc di + loop lp7 ; Multiplied (x5) by 2 making (x10) in src + +; Code deleted 1/15/90 MRN +; +; If no overflow has occurred, decrement power counter and loop +; through entire x10 routine. +; + +dpow: dec power + jz mcomplete + jmp lp0 ; major loop + +mcomplete: +if _LDATA + mov ax, parm3_ ; did all requested multiplications +else + mov ax, parm2_ +endif + +overflow: + if _LDATA + pop es + endif + cproce + + endps + end diff --git a/gfm/mul10l.c b/gfm/mul10l.c new file mode 100755 index 000000000..06a34bad5 --- /dev/null +++ b/gfm/mul10l.c @@ -0,0 +1,69 @@ +/* int _MulUnsArrByPwrOf10Limited(pa,n,dig) + * + * ARGUMENT + * unsigned pa[]; points to a 160bit number + * int n; power of 10 to multiply by (0..19) + * int dig; number of digits to multiply + * + * DESCRIPTION + * Multiplies the pa[] array by 10^n (0 +#include "gm.h" +#include "gmsystem.h" + + +int _MulUnsArrByPwrOf10Limited(pa,n,dig) +unsigned SHORT pa[]; +int n,dig; +{ + +int k,i,pow; +unsigned SHORT cop[10]; + + k=GM_SUCCESS; + pow=0; + + for (i=0;i<10;i++) + { + cop[i]=0; + } + + while((pow +#include "gm.h" +#include "gmsystem.h" + +DEC **MultiplyDecimalArrays(pDst,pSrc1,pSrc2,n) +DEC **pDst; +DEC **pSrc1, **pSrc2; +int n; +{ + int i; + +/* source must be supplied !! */ + _MacStart(GM_MULARR); + + if (!pSrc1 || !pSrc2 || !pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* Multiply the numbers */ + for (i=0; i +#include "gm.h" +#include "gmsystem.h" + +DEC **MultiplyDecimalArrayByDecimal(pDst,pSrc1,pSrc2,n) +DEC **pDst; +DEC **pSrc1, *pSrc2; +int n; +{ + int i; + DEC dcop2, *cop2=&dcop2; + mbool copyback; + +/* source must be supplied !! */ + _MacStart(GM_MULARRD); + + _MacInVar(pSrc2,GM_NULLARR); + if (!pSrc1 || !pDst) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULLARR); + } + + if (n<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULLARR); + } + +/* Copy Src2 in case it is part of destination array */ + _MacDCopy(cop2, pSrc2); + +/* check if backwards copy is necessary */ + copyback=(pDst > pSrc1); + +/* Multiply the numbers */ + i = copyback ? n-1 : 0; + while ((i=0)) { + (void) MultiplyDecimal(pDst[i], pSrc1[i], cop2); +/* MultiplyDecimal sets the error flag each time an error occurs */ + + if (copyback) + i--; + else + i++; + } + + + _MacRet(pDst); +} diff --git a/gfm/muldfd.c b/gfm/muldfd.c new file mode 100755 index 000000000..886047e03 --- /dev/null +++ b/gfm/muldfd.c @@ -0,0 +1,58 @@ +/* DEC *MultiplyDecimalByDouble(pDst,pSrc1,l) + * + * ARGUMENT + * pDst is a pointer to the destination DEC structure. + * pSrc1 is a ptr to the source1 DEC structure. + * l is the double to be multiplied by pSrc1 + * + * DESCRIPTION + * Multiplies the value 'l' by pSrc1 and puts the result + * in dest DEC structure. + * + * SIDE EFFECTS + * On overflow, the dest value is destroyed. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_CNVRE + * + * AUTHOR + * Andy Anderson 08-JUL-1987 1500 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MultiplyDecimalByDouble(pDst,pSrc1,l) +DEC *pDst,*pSrc1; +double l; +{ + DEC decS2, *pSrc2=&decS2, *pd; + + _MacStart(GM_MULDFD); + + /* Convert the double to a DEC */ + pSrc2=ConvDoubleToDecimal(pSrc2,l); + if (!pSrc2) { + if (pDst) + _MacDZero(pDst); + _MacRet(GM_NULL); + } + + pd = MultiplyDecimal(pDst,pSrc1,pSrc2); + + _MacRet(pd); +} diff --git a/gfm/mulid.c b/gfm/mulid.c new file mode 100755 index 000000000..b9fc36419 --- /dev/null +++ b/gfm/mulid.c @@ -0,0 +1,48 @@ +/* DEC *MultiplyDecimalByInt(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * int pSrc2; + * + * DESCRIPTION + * Multiplies pSrc1 times ConvIntToDecimal(pSrc2) & puts it Into pDst. + * pSrc1 and pSrc2 remain unchanged. Note that we always call the + * _MulDec80Bit() routine to do the actual multiply, sign chking, etc. + * + * SIDE EFFECTS + * *pDst is indeterminate on error. + * + * RETURNS + * Returns poInter to pDst if successful, otherwise a GM_NULL. The + * type error (GMOVERFLOW, GMUNDERFLOW, GMNOMEMORY) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 5-Mar-87 17:15 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC* MultiplyDecimalByInt(pDst,pSrc1,pSrc2) +DEC *pDst,*pSrc1; +int pSrc2; +{ + DEC *t; + + _MacStart(GM_MULID); + + t = MultiplyDecimalByLong(pDst,pSrc1,(long) pSrc2); + _MacRet(t); +} diff --git a/gfm/mulld.c b/gfm/mulld.c new file mode 100755 index 000000000..b4f52a2df --- /dev/null +++ b/gfm/mulld.c @@ -0,0 +1,58 @@ +/* DEC *MultiplyDecimalByLong(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * long pSrc2; + * + * DESCRIPTION + * Multiplies pSrc1 times ConvLongToDecimal(pSrc2) & puts it into pDst. + * pSrc1 and pSrc2 remain unchanged. Note that we always call the + * _MulDec80Bit() routine to do the actual multiply, sign chking, etc. + * + * SIDE EFFECTS + * *pDst is indeterminate on error. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GMOVERFLOW, GMUNDERFLOW, GMNOMEMORY) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 5-Mar-87 17:15 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC* MultiplyDecimalByLong(pDst,pSrc1,pSrc2) +DEC *pDst,*pSrc1; +long pSrc2; +{ + + DEC temp1,*tp1,*pd; + + _MacStart(GM_MULLD); + + /* init default pointer */ + tp1=&temp1; + + /* convert the long first, then call the multiply routine */ + (void) ConvLongToDecimal(tp1,pSrc2); + + pd = MultiplyDecimal(pDst,pSrc1,tp1); + + _MacRet(pd); + +} + diff --git a/gfm/mulstr.c b/gfm/mulstr.c new file mode 100755 index 000000000..f9c2daa05 --- /dev/null +++ b/gfm/mulstr.c @@ -0,0 +1,67 @@ +/* DEC *MultiplyAscii(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * pDst is a poiter to the destination DEC structure + * pSrc1 is a pointer to source1 ASCII string + * pSrc2 is a pointer to source2 ASCII string + * + * DESCRIPTION + * Multiplies the value in pSrc1 (ASCII) to the value in pSrc2 (ASCII) + * and puts the result in pDst DEC structure + * + * SIDE EFFECTS + * On error, the dest structure is undetermined. + * + * RETURNS + * Returns a pointer to the dest structure on success, + * otherwise returns a GM_NULL(a C false). On error, the error + * is in wGMError, unless an error was already there. + * + * POSSIBLE ERROR CODES + * + * GM_NULLSTRING + * GM_NOMEMORY + * GM_CNVRE + * GM_CNVRW + * GM_NAN + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Andy Anderson 20-Feb-87 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MultiplyAscii(pDst,pSrc1,pSrc2) +DEC *pDst; +char *pSrc1,*pSrc2; +{ + DEC dtmp1,dtmp2; + DEC *ps1,*ps2,*pd; + + _MacStart(GM_MULSTR); + + ps1=&dtmp1; + ps2=&dtmp2; + + /* convert ascii to DEC */ + ps1=ConvAsciiToDecimal(ps1,pSrc1); + if (!ps1) + _MacRet(GM_NULL); + + ps2=ConvAsciiToDecimal(ps2,pSrc2); + if (!ps2) + _MacRet(GM_NULL); + + pd = MultiplyDecimal(pDst,ps1,ps2); + + _MacRet(pd); +} diff --git a/gfm/muluid.c b/gfm/muluid.c new file mode 100755 index 000000000..31ab1501f --- /dev/null +++ b/gfm/muluid.c @@ -0,0 +1,48 @@ +/* DEC *MultiplyDecimalByUns(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * unsigned pSrc2; + * + * DESCRIPTION + * Multiplies pSrc1 times ConvIntToDecimal(pSrc2) & puts it Into pDst. + * pSrc1 and pSrc2 remain unchanged. Note that we always call the + * _MulDec80Bit() routine to do the actual multiply, sign chking, etc. + * + * SIDE EFFECTS + * *pDst is indeterminate on error. + * + * RETURNS + * Returns poInter to pDst if successful, otherwise a GM_NULL. The + * type error (GMOVERFLOW, GMUNDERFLOW, GMNOMEMORY) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 5-Mar-87 17:15 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC* MultiplyDecimalByUns(pDst,pSrc1,pSrc2) +DEC *pDst,*pSrc1; +unsigned int pSrc2; +{ + DEC *t; + + _MacStart(GM_MULUID); + + t = MultiplyDecimalByLong(pDst,pSrc1,(long) pSrc2); + _MacRet(t); +} diff --git a/gfm/mululd.c b/gfm/mululd.c new file mode 100755 index 000000000..57d42b3f6 --- /dev/null +++ b/gfm/mululd.c @@ -0,0 +1,54 @@ +/* DEC *MultiplyDecimalByUnsLong(pDst,pSrc1,pSrc2); + * + * ARGUMENT + * DEC *pDst; + * DEC *pSrc1; + * unsigned long pSrc2; + * + * DESCRIPTION + * Multiplies pSrc1 times ConvUnsLongToDecimal(pSrc2) & puts it + * into pDst. pSrc1 and pSrc2 remain unchanged. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns pointer to pDst if successful, otherwise a GM_NULL. The + * type error (GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError + * if wGMError didn't contain a previous error on entry. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * + * AUTHOR + * Andy Anderson 5-Mar-87 17:15 + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC* MultiplyDecimalByUnsLong(pDst,pSrc1,pSrc2) +DEC *pDst,*pSrc1; +unsigned long pSrc2; +{ + + DEC temp1,*tp1=&temp1,*pd; + + + _MacStart(GM_MULULD); + + /* convert the unsigned long first, then call the multiply routine */ + (void) ConvUnsLongToDecimal(tp1,pSrc2); + + pd = MultiplyDecimal(pDst,pSrc1,tp1); + + _MacRet(pd); +} + diff --git a/gfm/nfv.c b/gfm/nfv.c new file mode 100755 index 000000000..70b120cff --- /dev/null +++ b/gfm/nfv.c @@ -0,0 +1,83 @@ +/* DEC *NetFutureValue(net, flows, nflow, intr) + * + * ARGUMENT + * DEC *net, **flows, *intr; + * int nflow; + * + * DESCRIPTION + * Calculates the net future value of a series of cash flows. + * The nflow cash flows in the array flows are processed at interest + * rate intr. The net future value, rounded to two decimal places, + * is stored in net. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * net if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *NetFutureValue(net, flows, nflow, intr) +DEC *net, **flows, *intr; +int nflow; +{ + int i; + DEC dtemp, *temp=&dtemp, dopi, *opi=&dopi; + DEC dtnet, *tnet=&dtnet, dpow, *pow=&dpow; + + _MacStart(GM_NFV); + + if (nflow<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + _MacInVarD(intr); + if (!flows||!net) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + + for (i=0;idc.id+=2; + (void) _AddDec80Bit(opi, temp, &decOne); + + _MacDCopy(pow, (&decOne)); + + for (i=nflow-1;i>=0;i--) { + (void) _MulDec80Bit(temp, flows[i], pow); + (void) _AddDec80Bit(tnet, tnet, temp); + (void) _MulDec80Bit(pow, pow, opi); + } + + _ScaleDec80Bit(net, tnet, 2); + + _MacRet(net); +} diff --git a/gfm/nomtoeff.c b/gfm/nomtoeff.c new file mode 100755 index 000000000..1ffd96a7f --- /dev/null +++ b/gfm/nomtoeff.c @@ -0,0 +1,98 @@ +/* DEC *ConvNominalToEffective(eff, nom, nper) + * + * ARGUMENT + * DEC *eff,*nom; + * int nper; + * + * DESCRIPTION + * Changes a nominal interest rate (the stated percentage before + * compounding is considered) to an effective interest rate due to the + * effects of compound interest. nom is the nominal interest rate and + * nper is the number of compounding periods. The resulting effective + * rate is stored in eff. + * nper is the number of compounding periods, and is GM_CONTINUOUS + * for continuous compounding. + * finite compounding: eff = (1 + nom / nper) ^ nper + * continuous compounding: eff = e^nom - 1 + * + * SIDE EFFECTS + * eff is set to the effective percentage interest rate + * + * RETURNS + * eff if successful, otherwise GM_NULL + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gmsystem.h" + +DEC *ConvNominalToEffective(eff, nom, nper) +DEC *eff,*nom; +int nper; +{ + DEC dtemp, *temp=&dtemp, ddper, *dper=&ddper; + + _MacStart(GM_NOMTOEFF); + + _MacInVarD(nom); + _MacOutVarD(eff); + +/* nper must be >= 1 if not continuous compounding */ + if (((nper<=0)&&(nper!=GM_CONTINUOUS)) + ||CompareDecimal(nom,&decMinusHundred)<=0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + +/* convert percent to decimal */ + _MacDCopy(temp, nom); + temp->dc.id+=2; + + if (nper==GM_CONTINUOUS) { /* continuous compounding */ + if (_ExpDec80Bit(temp, temp)!=GM_SUCCESS) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + (void) _SubDec80Bit(temp, temp, &decOne); + } + else { /* finite compounding */ + (void) ConvLongToDecimal(dper, (long) nper); + (void) _DivDec80Bit(temp, temp, dper); + (void) _AddDec80Bit(temp, temp, &decOne); + + if (_IntPwrDec80Bit(temp, temp, nper)!=GM_SUCCESS) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + (void) _SubDec80Bit(temp, temp, &decOne); + } + +/* convert decimal to percent */ + if (temp->dc.id>=2) + temp->dc.id-=2; + else { + (void) ConvLongToDecimal(dper, 100L); + (void) _MulDec80Bit(temp, temp, dper); + } + + if (_Sq5UnsTo4Uns(temp)!=GM_SUCCESS) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + + _MacDCopy(eff,temp); + _MacRet(eff); +} diff --git a/gfm/npv.c b/gfm/npv.c new file mode 100755 index 000000000..564315b74 --- /dev/null +++ b/gfm/npv.c @@ -0,0 +1,82 @@ +/* DEC *NetPresentValue(net, flows, nflow, intr) + * + * ARGUMENT + * DEC *net, **flows, *intr; + * int nflow; + * + * DESCRIPTION + * Calculates the net present value of a series of cash flows. + * The nflow cash flows in the array flows are processed at interest + * rate intr. The net present value, rounded to two decimal places, + * is stored in net. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * net if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_ARGVAL + * + * AUTHOR + * Jared Levy + * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *NetPresentValue(net, flows, nflow, intr) +DEC *net, **flows, *intr; +int nflow; +{ + int i; + DEC dtemp, *temp=&dtemp, dooopi, *ooopi=&dooopi; + DEC dtnet, *tnet=&dtnet, dpow, *pow=&dpow; + + _MacStart(GM_NPV); + + if (nflow<0) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + _MacInVarD(intr); + if (!flows||!net) { + _MacErr(GM_NULLPOINTER); + _MacRet(GM_NULL); + } + for (i=0;idc.id+=2; + (void) _AddDec80Bit(temp, temp, &decOne); + (void) _DivDec80Bit(ooopi, &decOne, temp); + + _MacDCopy(pow, (&decOne)); + + for (i=0;i +#include "gm.h" +#include "gmsystem.h" + +DEC *AddPercent(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC dtemp, *temp=&dtemp; + + _MacStart(GM_PADD); + + _MacInVarD(pSrc2); + + _MacDCopy(temp, pSrc2); + temp->dc.id += 2; + (void) _AddDec80Bit(temp, temp, &decOne); + /* overflow not possible */ + + if (_Sq5UnsTo4Uns(temp)!=GM_SUCCESS) { + _MacErr(GM_ARGVAL); + _MacRet(GM_NULL); + } + pDst = MultiplyDecimalAndRound(pDst, pSrc1, temp, 2); + _MacRet(pDst); + /* error flag set by MultiplyDecimalAndRound */ +} diff --git a/gfm/pchange.c b/gfm/pchange.c new file mode 100755 index 000000000..bf22f35dc --- /dev/null +++ b/gfm/pchange.c @@ -0,0 +1,59 @@ +/* DEC *PercentChange(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pDst, *pSrc1, pSrc2; + * + * DESCRIPTION + * Calculates the percent change between pSrc1 and pSrc2 as a percentage + * of pSrc1, stroring the result in pDst. + * pDst = ((pSrc2 - pSrc1) / pSrc1) * 100 + * pDst is calculated to maximum precision. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *PercentChange(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC dtemp, *temp=&dtemp, ddiff, *diff=&ddiff; + + _MacStart(GM_PCHANGE); + + _MacInVarD(pSrc1); + _MacInVarD(pSrc2); + + _SubDec80Bit(diff, pSrc2, pSrc1); + + _MacDCopy(temp, pSrc1); + temp->dc.id += 2; + + pDst = DivideDecimal(pDst, diff, temp); + + _MacRet(pDst); + /* error flag set by DivideDecimal */ +} diff --git a/gfm/pdiv.c b/gfm/pdiv.c new file mode 100755 index 000000000..943c95799 --- /dev/null +++ b/gfm/pdiv.c @@ -0,0 +1,52 @@ +/* DEC *DividePercent(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pDst, *pSrc1, pSrc2; + * + * DESCRIPTION + * Divides pSrc1 by pSrc2 percent, stroring the result in pDst. + * pDst = pSrc1 / (pSrc2/100) + * pDst is rounded two 2 decimal places. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to the dest structure unless an error occurs, + * when it returns a GM_NULL. + * + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *DividePercent(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC dtemp, *temp=&dtemp; + + _MacStart(GM_PDIV); + + _MacDCopy(temp, pSrc2); + temp->dc.id += 2; + + pDst = DivideDecimalAndRound(pDst, pSrc1, temp, 2); + _MacRet(pDst); + /* error flag set by DivideDecimalAndRound */ +} diff --git a/gfm/pmul.c b/gfm/pmul.c new file mode 100755 index 000000000..270d3bad0 --- /dev/null +++ b/gfm/pmul.c @@ -0,0 +1,51 @@ +/* DEC *MultiplyPercent(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pDst, *pSrc1, pSrc2; + * + * DESCRIPTION + * Multiplies pSrc2 percent of pSrc1, stroring the result in pDst. + * pDst = pSrc1 * (pSrc2/100) + * pDst is rounded two 2 decimal places. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. + * + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *MultiplyPercent(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC dtemp, *temp=&dtemp; + + _MacStart(GM_PMUL); + + _MacDCopy(temp, pSrc2); + temp->dc.id += 2; + + pDst = MultiplyDecimalAndRound(pDst, pSrc1, temp, 2); + _MacRet(pDst); + /* error flag set by MultiplyDecimalAndRound */ +} diff --git a/gfm/pof.c b/gfm/pof.c new file mode 100755 index 000000000..6667aabb2 --- /dev/null +++ b/gfm/pof.c @@ -0,0 +1,53 @@ +/* DEC *PercentOf(pDst,pSrc1,pSrc2) + * + * ARGUMENT + * DEC *pDst, *pSrc1, pSrc2; + * + * DESCRIPTION + * Calculates the percent pSrc2 is of pSrc1, stroring the result in pDst. + * pDst = (pSrc2 / pSrc1) * 100 + * pDst is calculated to maximum precision. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * Returns a pointer to the dest structure unless overflow, + * when it returns a GM_NULL. + * + * POSSIBLE ERROR CODES + * + * GM_NULLPOINTER + * GM_NOMEMORY + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *PercentOf(pDst,pSrc1,pSrc2) +DEC *pDst; +DEC *pSrc1,*pSrc2; +{ + DEC dtemp, *temp=&dtemp; + + _MacStart(GM_POF); + + _MacDCopy(temp, pSrc1); + + + pDst = DivideDecimal(pDst, temp, pSrc2); + pDst->dc.id -= 2; + _MacRet(pDst); + /* error flag set by DivideDecimal */ +} diff --git a/gfm/predx.c b/gfm/predx.c new file mode 100755 index 000000000..da1e99d74 --- /dev/null +++ b/gfm/predx.c @@ -0,0 +1,52 @@ +/* DEC *PredictX(pDst, pSrc) + * + * ARGUMENT + * DEC *pDst, *pSrc; + * + * DESCRIPTION + * Using the previous values of A & B of the least squares line + * Y = A + B * X, calculates the predicted value of X corresponding to + * a given value of Y. pSrc contains Y, and the predicted X is returned + * to pDst. The globals pGMStatA and pGMStatB should already contain + * the values of A and B as computed and stored by LinearEstimate. + * X = (Y - A) / B + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * GM_DIV0 + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *PredictX(pDst, pSrc) +DEC *pDst, *pSrc; +{ + DEC dTemp, *pTemp=&dTemp; + _MacStart(GM_PREDX); + + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + (void) _SubDec80Bit(pTemp, pSrc, pGMStatA); + pDst = DivideDecimal(pDst, pTemp, pGMStatB); + + _MacRet(pDst); +} diff --git a/gfm/predy.c b/gfm/predy.c new file mode 100755 index 000000000..56b2d375b --- /dev/null +++ b/gfm/predy.c @@ -0,0 +1,51 @@ +/* DEC *PredictY(pDst, pSrc) + * + * ARGUMENT + * DEC *pDst, *pSrc; + * + * DESCRIPTION + * Using the previous values of A & B of the least squares line + * Y = A + B * X, calculates the predicted value of Y corresponding to + * a given value of X. pSrc contains X, and the predicted Y is returned + * to pDst. The globals pGMStatA and pGMStatB should already contain + * the values of A and B as computed and stored by LinearEstimate. + * + * SIDE EFFECTS + * None. + * + * RETURNS + * pDst if successful, otherwise GM_NULL. + * + * POSSIBLE ERRORS + * GM_NULLPOINTER + * GM_OVERFLOW + * GM_UNDERFLOW + * + * AUTHOR + * Jared Levy + * Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved. + * + * MODIFICATIONS + * + * + */ + +#include +#include "gm.h" +#include "gmsystem.h" + +DEC *PredictY(pDst, pSrc) +DEC *pDst, *pSrc; +{ + DEC dTemp, *pTemp=&dTemp; + _MacStart(GM_PREDY); + _MacInVarD(pSrc); + _MacOutVarD(pDst); + + if (!MultiplyDecimal(pTemp, pSrc, pGMStatB)) + _MacRet(GM_NULL); + + pDst = AddDecimal(pDst, pTemp, pGMStatA); + + _MacRet(pDst); +} diff --git a/gfm/prologue.h b/gfm/prologue.h new file mode 100755 index 000000000..4a814300e --- /dev/null +++ b/gfm/prologue.h @@ -0,0 +1,497 @@ + .xlist +; prologue.h - Macro Header for Microsoft C v3.0,4.0 & 5.x, ASM files. +; +; Copyright (C) 1984-1989 Greenleaf Software Inc. All rights reserved. +; +; Include this with all assembler modules, preceded by the proper +; version of MODEL.H to select the compiler and memory model. +; +; Modified 7/22/85 DK to add leading underscore char to names +; Modified 7/24/85 DN to add leading underscore char to alias label +; +;; David Nienhiser 11-JUN-1986 16:17:46.80 +; Modified for Microsoft C 4.0, compact and huge memory models. +;; David Nienhiser 14-JUL-1986 16:58:23.77 +; Added DefineVar and ReferVar macros & added LABEL option to +; ?cproc macro. +;; David Nienhiser 28-MAY-1987 10:06:18.71 +; Added GetDsAx macro. + + .xcref mesg,?cproc,?moderr + .cref + +mesg macro txt + if1 + %out txt + endif + endm + +?moderr = 0 + + ifndef _MSC3 + ifdef _MSC +_MSC3 equ 0 + endif + endif + + ifndef _MSC + ifdef _MSC3 +_MSC equ 3 + else + ?moderr = 1 + endif + else + if (_MSC ne 3) and (_MSC ne 4) and (_MSC ne 5) + ?moderr = 1 + endif + endif + + ifndef _HUGE +_HUGE equ 0 + endif + + + if _HUGE eq 1 + if (_LCODE ne 1) or (_LDATA ne 1) + mesg + ?moderr = 1 + endif + + endif + + if ?moderr eq 0 + mesg + if _MSC eq 3 + mesg + endif + + if (_MSC eq 4) or (_MSC eq 5) + mesg + endif + mesg + + if (_LCODE eq 0) and (_LDATA eq 0) and (_HUGE eq 0);;Small Model + mesg + endif + + if (_LCODE eq 0) and (_LDATA ne 0) and (_HUGE eq 0);; + mesg + endif + + if (_LCODE ne 0) and (_LDATA eq 0) and (_HUGE eq 0);;Medium Model + mesg + endif + + if (_LCODE ne 0) and (_LDATA ne 0) and (_HUGE eq 0);;Large Model + mesg + endif + + if (_LCODE ne 0) and (_LDATA ne 0) and (_HUGE ne 0);;Huge Model + mesg + endif + + +; Argument Base address on stack: +; +if _LCODE +@ab equ 6 ; arg offset if far call +parm1_ equ [bp+6] +parm2_ equ [bp+8] +parm3_ equ [bp+10] +parm4_ equ [bp+12] +parm5_ equ [bp+14] +parm6_ equ [bp+16] +parm7_ equ [bp+18] +parm8_ equ [bp+20] +parm9_ equ [bp+22] +parm10_ equ [bp+24] +parm11_ equ [bp+26] +parm12_ equ [bp+28] +parm14_ equ [bp+30] + else +@ab equ 4 ; ..if near call +parm1_ equ [bp+4] +parm2_ equ [bp+6] +parm3_ equ [bp+8] +parm4_ equ [bp+10] +parm5_ equ [bp+12] +parm6_ equ [bp+14] +parm7_ equ [bp+16] +parm8_ equ [bp+18] +parm9_ equ [bp+20] +parm10_ equ [bp+22] +parm11_ equ [bp+24] +parm12_ equ [bp+26] +parm13_ equ [bp+28] +parm14_ equ [bp+30] + endif + + if _LDATA +ptrsize equ 2 ; Number of words in pointer + else +ptrsize equ 1 + endif + + +; The DSEG and PSEG macros are defined to generate the appropriate GROUP +; and SEGMENT statements for the compiler and memory model in use. +; In addition, ENDDS and ENDPS are used to end these segments. +; +pseg macro segname + + ifb + mesg + error + endif + + if (_LCODE eq 0) ;; Small Model Program Segment +_TEXT segment byte public 'CODE' + assume cs:_TEXT + +endps ¯o +_TEXT ends + purge endps + &endm + endif + + if (_LCODE ne 0) ;; Medium or Large model +segname&_TEXT segment byte public 'CODE' + assume cs:&segname&_TEXT + +endps ¯o +segname&_TEXT ends + purge endps + &endm + endif + + endm ;;pseg + + +dseg macro + +DGROUP group _DATA +_DATA segment word public 'DATA' + assume ds:DGROUP + +endds ¯o +_DATA ends + purge endds + &endm + endm + +GetDsAx macro + mov ax,DGROUP + endm + +cproc macro name1,name2,name1s,name2s,storage,options + ?N1L = 0 + ?N2L = 0 + ifb + error label not specified + endif + irpc ?x,name1 + ?N1L = ?N1L + 1 + endm + + if ?N1L gt 8 + ifb + error short name for name1 not specified + else + ??NS = 0 + irpc ?x,name1s + ??NS = ??NS + 1 + endm + if ??NS gt 8 + error name1s too long + endif + endif + endif + + ifnb + irpc ?x,name2 + ?N2L = ?N2L + 1 + endm + if ?N2L gt 8 + ifb + error short name for name2 not specified + else + ??NS = 0 + irpc ?x,name2s + ??NS = ??NS + 1 + endm + if ??NS gt 8 + error name2s too long + endif + endif + endif + endif + ?cproc ,,storage, + endm ;; cproc + + ?cproc macro name1,name2,storage,options + public _&name1 + ifnb + public _&name2 + endif + if _LCODE +_&name1 proc far + ifnb +_&name2 label far + endif + else +_&name1 proc near + ifnb +_&name2 label near + endif + endif ;;_LCODE + +??LRA = 0 +??SDS = 0 ;; Save ds? +??SES = 0 ;; Save es? +??SSI = 1 ;; Default for push si +??SDI = 1 ;; Default for push di +??EXIT = 0 ;; exit point wanted? +??EREXIT = 0 ;; error exit point +??OKEXIT = 0 ;; OK Exit point + + ifnb + irp x, + + ifidn ,