home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: SHell self-extracting ARchive
(archive/shar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Newsgroup Content (archive/news)
| magic
| Supported |
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
100%
| dexvert
| Internet Message Format (text/imf)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| news, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| dexmagic
| PrintFox/Pagefox WEAK
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/329 Shell Archive Format
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
| |
100%
| xdgMime
| message/news
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 78 61 | 6e 74 68 21 6d 63 6e 63 |Path: xa|nth!mcnc|
|00000010| 21 67 61 74 65 63 68 21 | 75 6b 6d 61 21 63 77 6a |!gatech!|ukma!cwj|
|00000020| 63 63 21 68 61 6c 21 6e | 63 6f 61 73 74 21 61 6c |cc!hal!n|coast!al|
|00000030| 6c 62 65 72 79 0a 46 72 | 6f 6d 3a 20 6c 6a 7a 40 |lbery.Fr|om: ljz@|
|00000040| 66 78 67 72 70 2e 55 55 | 43 50 20 28 4c 6c 6f 79 |fxgrp.UU|CP (Lloy|
|00000050| 64 20 5a 75 73 6d 61 6e | 29 0a 4e 65 77 73 67 72 |d Zusman|).Newsgr|
|00000060| 6f 75 70 73 3a 20 63 6f | 6d 70 2e 73 6f 75 72 63 |oups: co|mp.sourc|
|00000070| 65 73 2e 6d 69 73 63 0a | 53 75 62 6a 65 63 74 3a |es.misc.|Subject:|
|00000080| 20 76 30 34 69 31 31 33 | 3a 20 41 72 62 69 74 72 | v04i113|: Arbitr|
|00000090| 61 72 79 20 50 72 65 63 | 69 73 69 6f 6e 20 4d 61 |ary Prec|ision Ma|
|000000a0| 74 68 20 4c 69 62 72 61 | 72 79 20 2d 2d 20 31 20 |th Libra|ry -- 1 |
|000000b0| 6f 66 20 35 0a 4d 65 73 | 73 61 67 65 2d 49 44 3a |of 5.Mes|sage-ID:|
|000000c0| 20 3c 38 38 31 30 30 35 | 31 39 34 34 2e 41 41 30 | <881005|1944.AA0|
|000000d0| 35 36 39 36 40 66 78 67 | 72 70 2e 66 78 2e 63 6f |5696@fxg|rp.fx.co|
|000000e0| 6d 3e 0a 44 61 74 65 3a | 20 37 20 4f 63 74 20 38 |m>.Date:| 7 Oct 8|
|000000f0| 38 20 30 30 3a 30 39 3a | 33 31 20 47 4d 54 0a 53 |8 00:09:|31 GMT.S|
|00000100| 65 6e 64 65 72 3a 20 61 | 6c 6c 62 65 72 79 40 6e |ender: a|llbery@n|
|00000110| 63 6f 61 73 74 2e 55 55 | 43 50 0a 52 65 70 6c 79 |coast.UU|CP.Reply|
|00000120| 2d 54 6f 3a 20 6c 6a 7a | 40 66 78 67 72 70 2e 55 |-To: ljz|@fxgrp.U|
|00000130| 55 43 50 20 28 4c 6c 6f | 79 64 20 5a 75 73 6d 61 |UCP (Llo|yd Zusma|
|00000140| 6e 29 0a 4c 69 6e 65 73 | 3a 20 36 34 30 0a 41 70 |n).Lines|: 640.Ap|
|00000150| 70 72 6f 76 65 64 3a 20 | 61 6c 6c 62 65 72 79 40 |proved: |allbery@|
|00000160| 6e 63 6f 61 73 74 2e 55 | 55 43 50 0a 0a 50 6f 73 |ncoast.U|UCP..Pos|
|00000170| 74 69 6e 67 2d 6e 75 6d | 62 65 72 3a 20 56 6f 6c |ting-num|ber: Vol|
|00000180| 75 6d 65 20 34 2c 20 49 | 73 73 75 65 20 31 31 33 |ume 4, I|ssue 113|
|00000190| 0a 53 75 62 6d 69 74 74 | 65 64 2d 62 79 3a 20 22 |.Submitt|ed-by: "|
|000001a0| 4c 6c 6f 79 64 20 5a 75 | 73 6d 61 6e 22 20 3c 6c |Lloyd Zu|sman" <l|
|000001b0| 6a 7a 40 66 78 67 72 70 | 2e 55 55 43 50 3e 0a 41 |jz@fxgrp|.UUCP>.A|
|000001c0| 72 63 68 69 76 65 2d 6e | 61 6d 65 3a 20 61 70 6d |rchive-n|ame: apm|
|000001d0| 6c 2f 50 61 72 74 31 0a | 0a 45 6e 63 6c 6f 73 65 |l/Part1.|.Enclose|
|000001e0| 64 20 79 6f 75 20 77 69 | 6c 6c 20 66 69 6e 64 20 |d you wi|ll find |
|000001f0| 74 68 65 20 41 72 62 69 | 74 72 61 72 79 20 50 72 |the Arbi|trary Pr|
|00000200| 65 63 69 73 69 6f 6e 20 | 4d 61 74 68 20 4c 69 62 |ecision |Math Lib|
|00000210| 72 61 72 79 20 28 31 20 | 6f 66 20 35 29 0a 0a 50 |rary (1 |of 5)..P|
|00000220| 6c 65 61 73 65 20 70 6f | 73 74 20 74 68 69 73 20 |lease po|st this |
|00000230| 74 6f 20 74 68 65 20 63 | 6f 6d 70 2e 73 6f 75 72 |to the c|omp.sour|
|00000240| 63 65 73 2e 6d 69 73 63 | 20 6e 65 77 73 67 72 6f |ces.misc| newsgro|
|00000250| 75 70 2e 0a 0a 49 20 66 | 69 6e 61 6c 6c 79 20 67 |up...I f|inally g|
|00000260| 6f 74 20 74 68 69 73 20 | 69 6e 74 6f 20 67 6f 6f |ot this |into goo|
|00000270| 64 20 65 6e 6f 75 67 68 | 20 73 68 61 70 65 20 74 |d enough| shape t|
|00000280| 6f 20 73 65 6e 64 20 6f | 75 74 20 74 6f 20 74 68 |o send o|ut to th|
|00000290| 65 20 6e 65 74 2e 20 54 | 6f 20 75 73 65 2c 0a 6a |e net. T|o use,.j|
|000002a0| 75 73 74 20 75 6e 73 68 | 61 72 20 74 68 65 20 35 |ust unsh|ar the 5|
|000002b0| 20 70 69 65 63 65 73 2c | 20 72 65 61 64 20 74 68 | pieces,| read th|
|000002c0| 65 20 52 45 41 44 4d 45 | 20 66 69 6c 65 2c 20 70 |e README| file, p|
|000002d0| 6f 73 73 69 62 6c 79 20 | 61 6c 74 65 72 20 74 68 |ossibly |alter th|
|000002e0| 65 20 6d 61 6b 65 66 69 | 6c 65 73 0a 74 6f 20 63 |e makefi|les.to c|
|000002f0| 6f 6e 66 6f 72 6d 20 74 | 6f 20 79 6f 75 72 20 73 |onform t|o your s|
|00000300| 79 73 74 65 6d 27 73 20 | 63 6f 6e 76 65 6e 74 69 |ystem's |conventi|
|00000310| 6f 6e 73 2c 20 61 6e 64 | 20 74 68 65 6e 20 74 79 |ons, and| then ty|
|00000320| 70 65 20 27 6d 61 6b 65 | 20 74 65 73 74 27 2e 0a |pe 'make| test'..|
|00000330| 0a 47 6f 6f 64 20 6c 75 | 63 6b 21 0a 0a 2d 2d 0a |.Good lu|ck!..--.|
|00000340| 20 20 4c 6c 6f 79 64 20 | 5a 75 73 6d 61 6e 20 20 | Lloyd |Zusman |
|00000350| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000360| 49 6e 74 65 72 6e 65 74 | 3a 20 20 6c 6a 7a 40 66 |Internet|: ljz@f|
|00000370| 78 2e 63 6f 6d 0a 20 20 | 4d 61 73 74 65 72 20 42 |x.com. |Master B|
|00000380| 79 74 65 20 53 6f 66 74 | 77 61 72 65 20 20 20 20 |yte Soft|ware |
|00000390| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 6f 72 | | or|
|000003a0| 20 6c 6a 7a 25 66 78 2e | 63 6f 6d 40 61 6d 65 73 | ljz%fx.|com@ames|
|000003b0| 2e 61 72 63 2e 6e 61 73 | 61 2e 67 6f 76 0a 20 20 |.arc.nas|a.gov. |
|000003c0| 4c 6f 73 20 47 61 74 6f | 73 2c 20 43 61 6c 69 66 |Los Gato|s, Calif|
|000003d0| 6f 72 6e 69 61 20 20 20 | 20 20 20 20 20 20 20 20 |ornia | |
|000003e0| 20 20 20 20 20 20 6f 72 | 20 66 78 67 72 70 21 6c | or| fxgrp!l|
|000003f0| 6a 7a 40 61 6d 65 73 2e | 61 72 63 2e 6e 61 73 61 |jz@ames.|arc.nasa|
|00000400| 2e 67 6f 76 0a 20 20 22 | 57 65 20 74 61 6b 65 20 |.gov. "|We take |
|00000410| 74 68 69 6e 67 73 20 77 | 65 6c 6c 20 69 6e 20 68 |things w|ell in h|
|00000420| 61 6e 64 2e 22 20 20 20 | 20 75 75 63 70 3a 20 20 |and." | uucp: |
|00000430| 2e 2e 2e 21 61 6d 65 73 | 21 66 78 67 72 70 21 6c |...!ames|!fxgrp!l|
|00000440| 6a 7a 0a 20 20 5b 20 6f | 75 72 20 49 6e 74 65 72 |jz. [ o|ur Inter|
|00000450| 6e 65 74 20 63 6f 6e 6e | 65 63 74 69 6f 6e 20 69 |net conn|ection i|
|00000460| 73 20 64 6f 77 6e 3a 20 | 75 73 65 20 75 75 63 70 |s down: |use uucp|
|00000470| 20 6f 72 20 6d 61 69 6c | 20 74 6f 20 74 68 65 20 | or mail| to the |
|00000480| 65 6e 74 72 79 20 61 62 | 6f 76 65 20 69 74 20 5d |entry ab|ove it ]|
|00000490| 0a 0a 23 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |..#-----|--------|
|000004a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 43 75 74 |--------|-----Cut|
|000004b0| 20 48 65 72 65 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d | Here---|--------|
|000004c0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 0a |--------|-------.|
|000004d0| 23 21 20 2f 62 69 6e 2f | 73 68 0a 23 20 54 68 69 |#! /bin/|sh.# Thi|
|000004e0| 73 20 69 73 20 61 20 73 | 68 65 6c 6c 20 61 72 63 |s is a s|hell arc|
|000004f0| 68 69 76 65 2e 20 20 52 | 65 6d 6f 76 65 20 61 6e |hive. R|emove an|
|00000500| 79 74 68 69 6e 67 20 62 | 65 66 6f 72 65 20 74 68 |ything b|efore th|
|00000510| 65 20 22 23 21 20 2f 62 | 69 6e 2f 73 68 22 20 6c |e "#! /b|in/sh" l|
|00000520| 69 6e 65 2c 0a 23 20 74 | 68 65 6e 20 75 6e 70 61 |ine,.# t|hen unpa|
|00000530| 63 6b 20 69 74 20 62 79 | 20 73 61 76 69 6e 67 20 |ck it by| saving |
|00000540| 69 74 20 69 6e 20 61 20 | 66 69 6c 65 20 61 6e 64 |it in a |file and|
|00000550| 20 74 79 70 69 6e 67 20 | 22 73 68 20 66 69 6c 65 | typing |"sh file|
|00000560| 2e 22 0a 23 0a 23 20 57 | 72 61 70 70 65 64 20 62 |.".#.# W|rapped b|
|00000570| 79 20 4c 6c 6f 79 64 20 | 5a 75 73 6d 61 6e 20 28 |y Lloyd |Zusman (|
|00000580| 6c 6a 7a 29 20 61 74 20 | 66 78 67 72 70 20 6f 6e |ljz) at |fxgrp on|
|00000590| 20 57 65 64 20 4f 63 74 | 20 20 35 20 31 32 3a 34 | Wed Oct| 5 12:4|
|000005a0| 31 3a 35 31 20 31 39 38 | 38 0a 23 0a 23 20 75 6e |1:51 198|8.#.# un|
|000005b0| 70 61 63 6b 73 20 77 69 | 74 68 20 64 65 66 61 75 |packs wi|th defau|
|000005c0| 6c 74 20 70 65 72 6d 69 | 73 73 69 6f 6e 73 0a 23 |lt permi|ssions.#|
|000005d0| 0a 23 20 43 6f 6e 74 65 | 6e 74 73 20 3a 20 52 45 |.# Conte|nts : RE|
|000005e0| 41 44 4d 45 20 46 55 4e | 43 54 49 4f 4e 53 0a 23 |ADME FUN|CTIONS.#|
|000005f0| 0a 69 66 20 60 74 65 73 | 74 20 21 20 2d 73 20 52 |.if `tes|t ! -s R|
|00000600| 45 41 44 4d 45 60 0a 74 | 68 65 6e 0a 65 63 68 6f |EADME`.t|hen.echo|
|00000610| 20 22 78 20 2d 20 52 45 | 41 44 4d 45 22 0a 73 65 | "x - RE|ADME".se|
|00000620| 64 20 27 73 2f 5e 58 2f | 2f 27 20 3e 20 52 45 41 |d 's/^X/|/' > REA|
|00000630| 44 4d 45 20 3c 3c 20 27 | 40 5c 45 4e 44 5f 4f 46 |DME << '|@\END_OF|
|00000640| 5f 46 49 4c 45 5f 52 45 | 41 44 4d 45 27 0a 58 0a |_FILE_RE|ADME'.X.|
|00000650| 58 20 20 20 20 09 20 20 | 20 20 09 41 72 62 69 74 |X . | .Arbit|
|00000660| 72 61 72 79 20 50 72 65 | 63 69 73 69 6f 6e 20 4d |rary Pre|cision M|
|00000670| 61 74 68 20 4c 69 62 72 | 61 72 79 0a 58 0a 58 54 |ath Libr|ary.X.XT|
|00000680| 68 65 20 41 72 62 69 74 | 72 61 72 79 20 50 72 65 |he Arbit|rary Pre|
|00000690| 63 69 73 69 6f 6e 20 4d | 61 74 68 20 4c 69 62 72 |cision M|ath Libr|
|000006a0| 61 72 79 20 69 73 20 61 | 20 73 65 72 69 65 73 20 |ary is a| series |
|000006b0| 6f 66 20 72 6f 75 74 69 | 6e 65 73 20 74 68 61 74 |of routi|nes that|
|000006c0| 0a 58 61 6c 6c 6f 77 73 | 20 74 68 65 20 75 73 65 |.Xallows| the use|
|000006d0| 72 20 74 6f 20 70 65 72 | 66 6f 72 6d 20 6d 61 74 |r to per|form mat|
|000006e0| 68 20 74 6f 20 61 6e 79 | 20 6c 65 76 65 6c 20 6f |h to any| level o|
|000006f0| 66 20 61 63 63 75 72 61 | 63 79 20 74 68 61 74 20 |f accura|cy that |
|00000700| 69 73 0a 58 64 65 73 69 | 72 65 64 2e 20 20 54 68 |is.Xdesi|red. Th|
|00000710| 65 73 65 20 41 50 4d 20 | 65 6e 74 69 74 69 65 73 |ese APM |entities|
|00000720| 20 28 22 41 50 4d 22 20 | 3d 3d 20 22 41 72 62 69 | ("APM" |== "Arbi|
|00000730| 74 72 61 72 79 20 50 72 | 65 63 69 73 69 6f 6e 20 |trary Pr|ecision |
|00000740| 4d 61 74 68 22 29 20 63 | 61 6e 0a 58 62 65 20 69 |Math") c|an.Xbe i|
|00000750| 6e 69 74 69 61 6c 69 7a | 65 64 20 66 72 6f 6d 20 |nitializ|ed from |
|00000760| 63 68 61 72 61 63 74 65 | 72 20 73 74 72 69 6e 67 |characte|r string|
|00000770| 73 20 6f 72 20 66 72 6f | 6d 20 6c 6f 6e 67 20 69 |s or fro|m long i|
|00000780| 6e 74 65 67 65 72 73 2c | 20 61 6e 64 20 74 68 65 |ntegers,| and the|
|00000790| 79 0a 58 63 61 6e 20 62 | 65 20 63 6f 6e 76 65 72 |y.Xcan b|e conver|
|000007a0| 74 65 64 20 62 61 63 6b | 20 69 6e 74 6f 20 63 68 |ted back| into ch|
|000007b0| 61 72 61 63 74 65 72 20 | 73 74 72 69 6e 67 73 20 |aracter |strings |
|000007c0| 62 79 20 61 20 72 6f 75 | 74 69 6e 65 20 74 68 61 |by a rou|tine tha|
|000007d0| 74 20 61 6c 6c 6f 77 73 | 0a 58 73 69 6d 70 6c 65 |t allows|.Xsimple|
|000007e0| 20 66 6f 72 6d 61 74 74 | 69 6e 67 2e 20 20 57 69 | formatt|ing. Wi|
|000007f0| 74 68 20 74 68 65 20 65 | 78 63 65 70 74 69 6f 6e |th the e|xception|
|00000800| 20 6f 66 20 74 68 65 20 | 72 6f 75 74 69 6e 65 73 | of the |routines|
|00000810| 20 74 68 61 74 20 64 6f | 0a 58 64 69 76 69 73 69 | that do|.Xdivisi|
|00000820| 6f 6e 2c 20 74 68 65 20 | 72 65 73 75 6c 74 73 20 |on, the |results |
|00000830| 6f 66 20 41 50 4d 20 6f | 70 65 72 61 74 69 6f 6e |of APM o|peration|
|00000840| 73 20 61 72 65 20 67 75 | 61 72 61 6e 74 65 65 64 |s are gu|aranteed|
|00000850| 20 74 6f 20 63 6f 6e 74 | 61 69 6e 0a 58 65 6e 6f | to cont|ain.Xeno|
|00000860| 75 67 68 20 70 72 65 63 | 69 73 69 6f 6e 20 74 6f |ugh prec|ision to|
|00000870| 20 68 6f 6c 64 20 65 78 | 61 63 74 20 76 61 6c 75 | hold ex|act valu|
|00000880| 65 73 2e 20 20 54 68 65 | 20 41 50 4d 20 72 6f 75 |es. The| APM rou|
|00000890| 74 69 6e 65 73 20 77 69 | 6c 6c 0a 58 61 75 74 6f |tines wi|ll.Xauto|
|000008a0| 6d 61 74 69 63 61 6c 6c | 79 20 61 6c 6c 6f 63 61 |maticall|y alloca|
|000008b0| 74 65 20 65 6e 6f 75 67 | 68 20 73 70 61 63 65 20 |te enoug|h space |
|000008c0| 69 6e 20 74 68 65 69 72 | 20 72 65 73 75 6c 74 73 |in their| results|
|000008d0| 20 74 6f 20 68 6f 6c 64 | 20 74 68 65 0a 58 70 72 | to hold| the.Xpr|
|000008e0| 6f 70 65 72 20 6e 75 6d | 62 65 72 20 6f 66 20 64 |oper num|ber of d|
|000008f0| 69 67 69 74 73 2e 0a 58 | 0a 58 54 68 65 20 41 50 |igits..X|.XThe AP|
|00000900| 4d 20 6d 61 74 68 20 69 | 73 20 64 6f 6e 65 20 6f |M math i|s done o|
|00000910| 6e 20 61 20 6e 65 77 20 | 64 61 74 61 20 74 79 70 |n a new |data typ|
|00000920| 65 20 63 61 6c 6c 65 64 | 20 22 41 50 4d 22 2e 20 |e called| "APM". |
|00000930| 20 54 68 69 73 20 69 73 | 0a 58 61 63 74 75 61 6c | This is|.Xactual|
|00000940| 6c 79 20 61 20 70 6f 69 | 6e 74 65 72 20 74 6f 20 |ly a poi|nter to |
|00000950| 61 20 73 74 72 75 63 74 | 75 72 65 2c 20 62 75 74 |a struct|ure, but|
|00000960| 20 74 68 65 20 63 6f 6e | 74 65 6e 74 73 20 6f 66 | the con|tents of|
|00000970| 20 74 68 65 20 73 74 72 | 75 63 74 75 72 65 0a 58 | the str|ucture.X|
|00000980| 73 68 6f 75 6c 64 20 6e | 65 76 65 72 20 62 65 20 |should n|ever be |
|00000990| 6d 61 6e 69 70 75 6c 61 | 74 65 64 3a 20 61 6c 6c |manipula|ted: all|
|000009a0| 20 6f 70 65 72 61 74 69 | 6f 6e 73 20 6f 6e 20 41 | operati|ons on A|
|000009b0| 50 4d 20 65 6e 74 69 74 | 69 65 73 20 61 72 65 20 |PM entit|ies are |
|000009c0| 64 6f 6e 65 0a 58 74 68 | 72 6f 75 67 68 20 61 20 |done.Xth|rough a |
|000009d0| 66 75 6e 63 74 69 6f 6e | 61 6c 20 69 6e 74 65 72 |function|al inter|
|000009e0| 66 61 63 65 2e 0a 58 0a | 58 41 50 4d 20 69 74 65 |face..X.|XAPM ite|
|000009f0| 6d 73 20 63 61 6e 20 62 | 65 20 72 65 70 72 65 73 |ms can b|e repres|
|00000a00| 65 6e 74 65 64 20 69 6e | 20 61 6e 79 20 6f 66 20 |ented in| any of |
|00000a10| 33 36 20 62 61 73 65 73 | 3a 20 32 20 74 68 72 6f |36 bases|: 2 thro|
|00000a20| 75 67 68 20 33 36 20 61 | 6e 64 0a 58 31 30 30 30 |ugh 36 a|nd.X1000|
|00000a30| 30 2e 20 20 54 68 65 20 | 6c 61 74 74 65 72 20 69 |0. The |latter i|
|00000a40| 73 20 71 75 69 74 65 20 | 75 73 65 66 75 6c 3a 20 |s quite |useful: |
|00000a50| 6e 75 6d 62 65 72 73 20 | 74 68 61 74 20 61 72 65 |numbers |that are|
|00000a60| 20 72 65 70 72 65 73 65 | 6e 74 65 64 20 69 6e 0a | represe|nted in.|
|00000a70| 58 62 61 73 65 73 20 74 | 68 61 74 20 61 72 65 20 |Xbases t|hat are |
|00000a80| 70 6f 77 65 72 73 20 6f | 66 20 31 30 20 61 72 65 |powers o|f 10 are|
|00000a90| 20 71 75 69 74 65 20 65 | 61 73 79 20 74 6f 20 61 | quite e|asy to a|
|00000aa0| 63 63 75 72 61 74 65 6c | 79 20 63 6f 6e 76 65 72 |ccuratel|y conver|
|00000ab0| 74 20 74 6f 0a 58 61 6e | 64 20 66 72 6f 6d 20 63 |t to.Xan|d from c|
|00000ac0| 68 61 72 61 63 74 65 72 | 20 73 74 72 69 6e 67 73 |haracter| strings|
|00000ad0| 20 63 6f 6e 74 61 69 6e | 69 6e 67 20 74 68 65 69 | contain|ing thei|
|00000ae0| 72 20 64 65 63 69 6d 61 | 6c 20 72 65 70 72 65 73 |r decima|l repres|
|00000af0| 65 6e 74 61 74 69 6f 6e | 2c 0a 58 61 6e 64 20 31 |entation|,.Xand 1|
|00000b00| 30 30 30 30 20 69 73 20 | 74 68 65 20 6c 61 72 67 |0000 is |the larg|
|00000b10| 65 73 74 20 70 6f 77 65 | 72 20 6f 66 20 31 30 20 |est powe|r of 10 |
|00000b20| 74 68 61 74 20 66 69 74 | 73 20 69 6e 74 6f 20 61 |that fit|s into a|
|00000b30| 20 73 68 6f 72 74 20 69 | 6e 74 65 67 65 72 0a 58 | short i|nteger.X|
|00000b40| 28 31 36 20 62 69 74 73 | 29 2e 20 20 54 68 65 20 |(16 bits|). The |
|00000b50| 62 61 73 65 20 6d 75 73 | 74 20 66 69 74 20 69 6e |base mus|t fit in|
|00000b60| 74 6f 20 61 20 73 68 6f | 72 74 20 69 6e 74 65 67 |to a sho|rt integ|
|00000b70| 65 72 20 73 69 6e 63 65 | 20 63 61 6c 63 75 6c 61 |er since| calcula|
|00000b80| 74 69 6f 6e 73 0a 58 69 | 6e 74 65 72 6e 61 6c 20 |tions.Xi|nternal |
|00000b90| 74 6f 20 74 68 65 20 41 | 50 4d 20 72 6f 75 74 69 |to the A|PM routi|
|00000ba0| 6e 65 73 20 6e 65 65 64 | 20 75 70 20 74 6f 20 74 |nes need| up to t|
|00000bb0| 77 69 63 65 20 61 73 20 | 6d 75 63 68 20 73 74 6f |wice as |much sto|
|00000bc0| 72 61 67 65 20 61 73 20 | 69 73 0a 58 6e 65 65 64 |rage as |is.Xneed|
|00000bd0| 65 64 20 74 6f 20 68 6f | 6c 64 20 74 68 65 20 62 |ed to ho|ld the b|
|00000be0| 61 73 65 2c 20 61 6e 64 | 20 74 68 65 20 6c 61 72 |ase, and| the lar|
|00000bf0| 67 65 73 74 20 75 6e 69 | 74 20 77 65 20 63 61 6e |gest uni|t we can|
|00000c00| 20 64 65 61 6c 20 77 69 | 74 68 20 65 61 73 69 6c | deal wi|th easil|
|00000c10| 79 0a 58 69 73 20 61 20 | 6c 6f 6e 67 20 69 6e 74 |y.Xis a |long int|
|00000c20| 65 67 65 72 20 28 32 20 | 73 68 6f 72 74 73 29 2e |eger (2 |shorts).|
|00000c30| 20 20 49 74 20 74 75 72 | 6e 73 20 6f 75 74 20 74 | It tur|ns out t|
|00000c40| 68 61 74 20 73 70 65 65 | 64 20 69 6d 70 72 6f 76 |hat spee|d improv|
|00000c50| 65 73 20 61 6e 64 0a 58 | 6d 65 6d 6f 72 79 20 75 |es and.X|memory u|
|00000c60| 73 61 67 65 20 64 65 63 | 72 65 61 73 65 73 20 61 |sage dec|reases a|
|00000c70| 73 20 74 68 65 20 6d 61 | 67 6e 69 74 75 64 65 20 |s the ma|gnitude |
|00000c80| 6f 66 20 74 68 65 20 62 | 61 73 65 20 69 6e 63 72 |of the b|ase incr|
|00000c90| 65 61 73 65 73 2c 20 73 | 6f 20 62 61 73 65 0a 58 |eases, s|o base.X|
|00000ca0| 31 30 30 30 30 20 69 73 | 20 61 20 77 69 6e 20 69 |10000 is| a win i|
|00000cb0| 6e 20 62 6f 74 68 20 63 | 6f 75 6e 74 73 2e 20 20 |n both c|ounts. |
|00000cc0| 49 20 68 61 76 65 20 64 | 6f 6e 65 20 73 6f 6d 65 |I have d|one some|
|00000cd0| 20 69 6e 66 6f 72 6d 61 | 6c 20 62 65 6e 63 68 6d | informa|l benchm|
|00000ce0| 61 72 6b 73 0a 58 69 6e | 20 77 68 69 63 68 20 62 |arks.Xin| which b|
|00000cf0| 61 73 65 20 31 30 30 30 | 30 20 69 73 20 36 20 74 |ase 1000|0 is 6 t|
|00000d00| 6f 20 31 30 20 74 69 6d | 65 73 20 66 61 73 74 65 |o 10 tim|es faste|
|00000d10| 72 20 74 68 61 6e 20 62 | 61 73 65 20 31 30 20 66 |r than b|ase 10 f|
|00000d20| 6f 72 20 6e 75 6d 62 65 | 72 73 0a 58 77 69 74 68 |or numbe|rs.Xwith|
|00000d30| 20 31 35 20 2d 20 32 30 | 20 64 65 63 69 6d 61 6c | 15 - 20| decimal|
|00000d40| 20 64 69 67 69 74 73 20 | 6f 66 20 70 72 65 63 69 | digits |of preci|
|00000d50| 73 69 6f 6e 2e 0a 58 0a | 58 41 6c 74 68 6f 75 67 |sion..X.|XAlthoug|
|00000d60| 68 20 74 68 65 72 65 20 | 69 73 20 61 20 6d 75 6c |h there |is a mul|
|00000d70| 74 69 74 75 64 65 20 6f | 66 20 62 61 73 65 73 2c |titude o|f bases,|
|00000d80| 20 74 68 65 72 65 20 69 | 73 20 61 73 20 79 65 74 | there i|s as yet|
|00000d90| 20 6e 6f 20 70 72 6f 76 | 69 73 69 6f 6e 0a 58 66 | no prov|ision.Xf|
|00000da0| 6f 72 20 63 6f 6e 76 65 | 72 73 69 6f 6e 20 66 72 |or conve|rsion fr|
|00000db0| 6f 6d 20 6f 6e 65 20 62 | 61 73 65 20 74 6f 20 61 |om one b|ase to a|
|00000dc0| 6e 6f 74 68 65 72 2c 20 | 65 78 63 65 70 74 20 66 |nother, |except f|
|00000dd0| 6f 72 20 74 68 65 20 73 | 70 65 63 69 61 6c 20 63 |or the s|pecial c|
|00000de0| 61 73 65 0a 58 6f 66 20 | 63 6f 6e 76 65 72 74 69 |ase.Xof |converti|
|00000df0| 6e 67 20 62 65 74 77 65 | 65 6e 20 62 61 73 65 2d |ng betwe|en base-|
|00000e00| 31 30 20 63 68 61 72 61 | 63 74 65 72 20 73 74 72 |10 chara|cter str|
|00000e10| 69 6e 67 73 20 61 6e 64 | 20 62 61 73 65 2d 31 30 |ings and| base-10|
|00000e20| 30 30 30 20 41 50 4d 0a | 58 76 61 6c 75 65 73 2e |000 APM.|Xvalues.|
|00000e30| 20 20 41 6c 6c 20 74 68 | 65 20 69 6e 70 75 74 20 | All th|e input |
|00000e40| 41 50 4d 20 70 61 72 61 | 6d 65 74 65 72 73 20 74 |APM para|meters t|
|00000e50| 6f 20 61 6e 79 20 67 69 | 76 65 6e 20 41 50 4d 20 |o any gi|ven APM |
|00000e60| 72 6f 75 74 69 6e 65 20 | 6d 75 73 74 20 62 65 0a |routine |must be.|
|00000e70| 58 6f 66 20 74 68 65 20 | 73 61 6d 65 20 62 61 73 |Xof the |same bas|
|00000e80| 65 2e 0a 58 0a 58 54 68 | 65 20 63 61 6c 6c 65 72 |e..X.XTh|e caller|
|00000e90| 20 6d 75 73 74 20 69 6e | 69 74 69 61 6c 69 7a 65 | must in|itialize|
|00000ea0| 20 61 6c 6c 20 41 50 4d | 20 76 61 6c 75 65 73 20 | all APM| values |
|00000eb0| 62 65 66 6f 72 65 20 74 | 68 65 20 72 6f 75 74 69 |before t|he routi|
|00000ec0| 6e 65 73 20 63 61 6e 0a | 58 6f 70 65 72 61 74 65 |nes can.|Xoperate|
|00000ed0| 20 6f 6e 20 74 68 65 6d | 20 28 69 6e 63 6c 75 64 | on them| (includ|
|00000ee0| 69 6e 67 20 74 68 65 20 | 76 61 6c 75 65 73 20 69 |ing the |values i|
|00000ef0| 6e 74 65 6e 64 65 64 20 | 74 6f 20 63 6f 6e 74 61 |ntended |to conta|
|00000f00| 69 6e 20 72 65 73 75 6c | 74 73 20 6f 66 0a 58 63 |in resul|ts of.Xc|
|00000f10| 61 6c 63 75 6c 61 74 69 | 6f 6e 73 29 2e 20 20 4f |alculati|ons). O|
|00000f20| 6e 63 65 20 74 68 69 73 | 20 69 6e 69 74 69 61 6c |nce this| initial|
|00000f30| 69 7a 61 74 69 6f 6e 20 | 69 73 20 64 6f 6e 65 2c |ization |is done,|
|00000f40| 20 74 68 65 20 75 73 65 | 72 20 6e 65 76 65 72 20 | the use|r never |
|00000f50| 6e 65 65 64 73 0a 58 74 | 6f 20 77 6f 72 72 79 20 |needs.Xt|o worry |
|00000f60| 61 62 6f 75 74 20 72 65 | 73 69 7a 69 6e 67 20 74 |about re|sizing t|
|00000f70| 68 65 20 41 50 4d 20 76 | 61 6c 75 65 73 2c 20 61 |he APM v|alues, a|
|00000f80| 73 20 74 68 69 73 20 69 | 73 20 68 61 6e 64 6c 65 |s this i|s handle|
|00000f90| 64 20 69 6e 73 69 64 65 | 20 74 68 65 0a 58 41 50 |d inside| the.XAP|
|00000fa0| 4d 20 72 6f 75 74 69 6e | 65 73 20 61 6e 64 20 69 |M routin|es and i|
|00000fb0| 73 20 74 6f 74 61 6c 6c | 79 20 69 6e 76 69 73 69 |s totall|y invisi|
|00000fc0| 62 6c 65 20 74 6f 20 74 | 68 65 20 75 73 65 72 2e |ble to t|he user.|
|00000fd0| 0a 58 0a 58 54 68 65 20 | 72 65 73 75 6c 74 20 6f |.X.XThe |result o|
|00000fe0| 66 20 61 20 41 50 4d 20 | 6f 70 65 72 61 74 69 6f |f a APM |operatio|
|00000ff0| 6e 20 63 61 6e 6e 6f 74 | 20 62 65 20 6f 6e 65 20 |n cannot| be one |
|00001000| 6f 66 20 74 68 65 20 6f | 74 68 65 72 20 41 50 4d |of the o|ther APM|
|00001010| 20 6f 70 65 72 61 6e 64 | 73 2e 0a 58 49 66 20 79 | operand|s..XIf y|
|00001020| 6f 75 20 77 61 6e 74 20 | 74 68 69 73 20 74 6f 20 |ou want |this to |
|00001030| 62 65 20 74 68 65 20 63 | 61 73 65 2c 20 79 6f 75 |be the c|ase, you|
|00001040| 20 6d 75 73 74 20 70 75 | 74 20 74 68 65 20 72 65 | must pu|t the re|
|00001050| 73 75 6c 74 20 69 6e 74 | 6f 20 61 0a 58 74 65 6d |sult int|o a.Xtem|
|00001060| 70 6f 72 61 72 79 20 76 | 61 72 69 61 62 6c 65 20 |porary v|ariable |
|00001070| 61 6e 64 20 74 68 65 6e | 20 61 73 73 69 67 6e 20 |and then| assign |
|00001080| 69 74 20 74 6f 20 74 68 | 65 20 61 70 70 72 6f 70 |it to th|e approp|
|00001090| 72 69 61 74 65 20 6f 70 | 65 72 61 6e 64 2e 0a 58 |riate op|erand..X|
|000010a0| 0a 58 41 6c 6c 20 6f 66 | 20 74 68 65 20 72 6f 75 |.XAll of| the rou|
|000010b0| 74 69 6e 65 73 20 73 65 | 74 20 74 68 65 20 76 61 |tines se|t the va|
|000010c0| 6c 75 65 20 6f 66 20 61 | 20 67 6c 6f 62 61 6c 20 |lue of a| global |
|000010d0| 69 6e 74 65 67 65 72 20 | 63 61 6c 6c 65 64 0a 58 |integer |called.X|
|000010e0| 22 61 70 6d 5f 65 72 72 | 6e 6f 22 20 74 6f 20 61 |"apm_err|no" to a|
|000010f0| 6e 20 65 72 72 6f 72 20 | 73 74 61 74 75 73 3a 20 |n error |status: |
|00001100| 30 20 6d 65 61 6e 73 20 | 74 68 65 20 6f 70 65 72 |0 means |the oper|
|00001110| 61 74 69 6f 6e 20 73 75 | 63 63 65 65 64 65 64 2c |ation su|cceeded,|
|00001120| 20 3e 20 30 0a 58 6d 65 | 61 6e 73 20 74 68 65 72 | > 0.Xme|ans ther|
|00001130| 65 20 77 61 73 20 61 20 | 77 61 72 6e 69 6e 67 20 |e was a |warning |
|00001140| 62 75 74 20 74 68 61 74 | 20 74 68 65 72 65 20 73 |but that| there s|
|00001150| 74 69 6c 6c 20 69 73 20 | 61 20 72 65 73 75 6c 74 |till is |a result|
|00001160| 2c 20 61 6e 64 20 3c 20 | 30 0a 58 6d 65 61 6e 73 |, and < |0.Xmeans|
|00001170| 20 74 68 65 72 65 20 77 | 61 73 20 61 6e 20 65 72 | there w|as an er|
|00001180| 72 6f 72 20 77 68 69 63 | 68 20 70 72 6f 68 69 62 |ror whic|h prohib|
|00001190| 69 74 65 64 20 74 68 65 | 20 6f 70 65 72 61 74 69 |ited the| operati|
|000011a0| 6f 6e 20 66 72 6f 6d 0a | 58 63 6f 6d 70 6c 65 74 |on from.|Xcomplet|
|000011b0| 69 6e 67 2e 20 20 45 78 | 63 65 70 74 20 77 68 65 |ing. Ex|cept whe|
|000011c0| 72 65 20 6f 74 68 65 72 | 77 69 73 65 20 6e 6f 74 |re other|wise not|
|000011d0| 65 64 2c 20 74 68 65 20 | 72 6f 75 74 69 6e 65 73 |ed, the |routines|
|000011e0| 20 72 65 74 75 72 6e 20 | 74 68 69 73 0a 58 73 61 | return |this.Xsa|
|000011f0| 6d 65 20 73 74 61 74 75 | 73 20 76 61 6c 75 65 2e |me statu|s value.|
|00001200| 0a 58 0a 58 54 68 65 20 | 63 61 6c 6c 65 72 20 68 |.X.XThe |caller h|
|00001210| 61 73 20 74 68 65 20 6f | 70 74 69 6f 6e 20 6f 66 |as the o|ption of|
|00001220| 20 72 65 67 69 73 74 65 | 72 69 6e 67 20 61 20 68 | registe|ring a h|
|00001230| 61 6e 64 6c 65 72 20 66 | 6f 72 20 65 72 72 6f 72 |andler f|or error|
|00001240| 73 20 61 6e 64 0a 58 77 | 61 72 6e 69 6e 67 73 2e |s and.Xw|arnings.|
|00001250| 20 20 49 66 20 74 68 69 | 73 20 68 61 73 20 62 65 | If thi|s has be|
|00001260| 65 6e 20 64 6f 6e 65 2c | 20 74 68 65 20 68 61 6e |en done,| the han|
|00001270| 64 6c 65 72 20 77 69 6c | 6c 20 62 65 20 69 6e 76 |dler wil|l be inv|
|00001280| 6f 6b 65 64 20 61 73 20 | 65 61 63 68 0a 58 41 50 |oked as |each.XAP|
|00001290| 4d 20 72 6f 75 74 69 6e | 65 20 72 65 74 75 72 6e |M routin|e return|
|000012a0| 73 2c 20 61 6e 64 20 69 | 74 20 77 69 6c 6c 20 62 |s, and i|t will b|
|000012b0| 65 20 70 61 73 73 65 64 | 20 61 70 70 72 6f 70 72 |e passed| appropr|
|000012c0| 69 61 74 65 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e |iate inf|ormation|
|000012d0| 20 61 73 0a 58 74 6f 20 | 74 68 65 20 73 74 61 74 | as.Xto |the stat|
|000012e0| 75 73 20 6f 66 20 74 68 | 65 20 63 61 6c 6c 20 74 |us of th|e call t|
|000012f0| 6f 20 74 68 69 73 20 41 | 50 4d 20 72 6f 75 74 69 |o this A|PM routi|
|00001300| 6e 65 2e 20 20 57 69 74 | 68 20 61 20 72 65 67 69 |ne. Wit|h a regi|
|00001310| 73 74 65 72 65 64 0a 58 | 65 72 72 6f 72 20 68 61 |stered.X|error ha|
|00001320| 6e 64 6c 65 72 20 69 74 | 20 69 73 20 6e 6f 74 20 |ndler it| is not |
|00001330| 6e 65 63 65 73 73 61 72 | 79 20 66 6f 72 20 74 68 |necessar|y for th|
|00001340| 65 20 63 61 6c 6c 65 72 | 20 74 6f 20 63 68 65 63 |e caller| to chec|
|00001350| 6b 20 74 68 65 20 65 72 | 72 6f 72 0a 58 63 6f 64 |k the er|ror.Xcod|
|00001360| 65 20 61 66 74 65 72 20 | 65 61 63 68 20 63 61 6c |e after |each cal|
|00001370| 6c 20 74 6f 20 61 20 41 | 50 4d 20 72 6f 75 74 69 |l to a A|PM routi|
|00001380| 6e 65 2e 0a 58 0a 58 46 | 6f 72 20 65 61 73 65 20 |ne..X.XF|or ease |
|00001390| 6f 66 20 64 65 62 75 67 | 67 69 6e 67 2c 20 65 61 |of debug|ging, ea|
|000013a0| 63 68 20 41 50 4d 20 72 | 6f 75 74 69 6e 65 20 69 |ch APM r|outine i|
|000013b0| 73 20 61 63 74 75 61 6c | 6c 79 20 61 20 6d 61 63 |s actual|ly a mac|
|000013c0| 72 6f 20 74 68 61 74 20 | 73 61 76 65 73 0a 58 74 |ro that |saves.Xt|
|000013d0| 68 65 20 66 69 6c 65 20 | 6e 61 6d 65 20 61 6e 64 |he file |name and|
|000013e0| 20 6c 69 6e 65 20 6e 75 | 6d 62 65 72 20 61 6e 64 | line nu|mber and|
|000013f0| 20 74 68 65 6e 20 63 61 | 6c 6c 73 20 61 20 66 75 | then ca|lls a fu|
|00001400| 6e 63 74 69 6f 6e 20 6f | 66 20 61 20 73 6c 69 67 |nction o|f a slig|
|00001410| 68 74 6c 79 0a 58 64 69 | 66 66 65 72 65 6e 74 20 |htly.Xdi|fferent |
|00001420| 6e 61 6d 65 2e 20 20 54 | 68 69 73 20 61 6c 6c 6f |name. T|his allo|
|00001430| 77 73 20 74 68 65 20 65 | 72 72 6f 72 20 68 61 6e |ws the e|rror han|
|00001440| 64 6c 65 72 20 74 6f 20 | 72 65 70 6f 72 74 20 74 |dler to |report t|
|00001450| 68 65 20 65 78 61 63 74 | 0a 58 6c 6f 63 61 74 69 |he exact|.Xlocati|
|00001460| 6f 6e 20 6f 66 20 74 68 | 65 20 41 50 4d 20 6f 70 |on of th|e APM op|
|00001470| 65 72 61 74 69 6f 6e 20 | 77 68 69 63 68 20 63 61 |eration |which ca|
|00001480| 75 73 65 64 20 74 68 65 | 20 65 72 72 6f 72 2e 20 |used the| error. |
|00001490| 20 54 68 65 20 6d 61 63 | 72 6f 73 20 79 6f 75 0a | The mac|ros you.|
|000014a0| 58 77 69 6c 6c 20 75 73 | 65 20 68 61 76 65 20 6e |Xwill us|e have n|
|000014b0| 61 6d 65 73 20 6f 66 20 | 74 68 65 20 66 6f 72 6d |ames of |the form|
|000014c0| 20 22 61 70 6d 52 6f 75 | 74 69 6e 65 4e 61 6d 65 | "apmRou|tineName|
|000014d0| 22 2e 20 20 54 6f 20 67 | 65 74 20 74 68 65 0a 58 |". To g|et the.X|
|000014e0| 63 6f 72 72 65 73 70 6f | 6e 64 69 6e 67 20 61 63 |correspo|nding ac|
|000014f0| 74 75 61 6c 20 66 75 6e | 63 74 69 6f 6e 20 6e 61 |tual fun|ction na|
|00001500| 6d 65 20 28 73 61 79 2c | 20 77 68 65 6e 20 75 73 |me (say,| when us|
|00001510| 69 6e 67 20 61 20 64 65 | 62 75 67 67 65 72 29 2c |ing a de|bugger),|
|00001520| 0a 58 72 65 70 6c 61 63 | 65 20 61 6c 6c 20 63 61 |.Xreplac|e all ca|
|00001530| 70 69 74 61 6c 20 6c 65 | 74 74 65 72 73 20 77 69 |pital le|tters wi|
|00001540| 74 68 20 61 6e 20 75 6e | 64 65 72 62 61 72 20 28 |th an un|derbar (|
|00001550| 22 5f 22 29 20 66 6f 6c | 6c 6f 77 65 64 20 62 79 |"_") fol|lowed by|
|00001560| 20 69 74 73 0a 58 6c 6f | 77 65 72 2d 63 61 73 65 | its.Xlo|wer-case|
|00001570| 20 63 6f 75 6e 74 65 72 | 70 61 72 74 2e 20 20 46 | counter|part. F|
|00001580| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 66 6f 72 20 |or examp|le, for |
|00001590| 61 20 68 79 70 6f 74 68 | 65 74 69 63 61 6c 20 72 |a hypoth|etical r|
|000015a0| 6f 75 74 69 6e 65 0a 58 | 63 61 6c 6c 65 64 20 22 |outine.X|called "|
|000015b0| 61 70 6d 52 6f 75 74 69 | 6e 65 4e 61 6d 65 22 2c |apmRouti|neName",|
|000015c0| 20 74 68 65 20 61 63 74 | 75 61 6c 20 66 75 6e 63 | the act|ual func|
|000015d0| 74 69 6f 6e 20 77 69 6c | 6c 20 62 65 20 6e 61 6d |tion wil|l be nam|
|000015e0| 65 64 0a 58 22 61 70 6d | 5f 72 6f 75 74 69 6e 65 |ed.X"apm|_routine|
|000015f0| 5f 6e 61 6d 65 22 2e 20 | 20 59 6f 75 20 73 68 6f |_name". | You sho|
|00001600| 75 6c 64 20 6e 65 76 65 | 72 20 65 78 70 6c 69 63 |uld neve|r explic|
|00001610| 69 74 6c 79 20 63 61 6c | 6c 20 74 68 65 20 61 63 |itly cal|l the ac|
|00001620| 74 75 61 6c 0a 58 66 75 | 6e 63 74 69 6f 6e 2e 0a |tual.Xfu|nction..|
|00001630| 58 0a 58 59 6f 75 20 73 | 68 6f 75 6c 64 20 61 76 |X.XYou s|hould av|
|00001640| 6f 69 64 20 75 73 69 6e | 67 20 73 79 6d 62 6f 6c |oid usin|g symbol|
|00001650| 73 20 74 68 61 74 20 73 | 74 61 72 74 20 77 69 74 |s that s|tart wit|
|00001660| 68 20 74 68 65 20 63 68 | 61 72 61 63 74 65 72 73 |h the ch|aracters|
|00001670| 20 22 41 50 4d 5f 22 0a | 58 61 6e 64 20 22 61 70 | "APM_".|Xand "ap|
|00001680| 6d 5f 22 2c 20 61 73 20 | 74 68 65 79 20 6d 61 79 |m_", as |they may|
|00001690| 20 63 6c 61 73 68 20 77 | 69 74 68 20 73 79 6d 62 | clash w|ith symb|
|000016a0| 6f 6c 73 20 74 68 61 74 | 20 61 6c 72 65 61 64 79 |ols that| already|
|000016b0| 20 65 78 69 73 74 20 69 | 6e 20 74 68 65 0a 58 41 | exist i|n the.XA|
|000016c0| 50 4d 20 4c 69 62 72 61 | 72 79 2e 0a 58 0a 58 54 |PM Libra|ry..X.XT|
|000016d0| 68 65 72 65 20 69 73 20 | 6f 6e 65 20 72 6f 75 74 |here is |one rout|
|000016e0| 69 6e 65 20 66 6f 72 20 | 65 61 63 68 20 62 61 73 |ine for |each bas|
|000016f0| 69 63 20 61 72 69 74 68 | 6d 65 74 69 63 20 6f 70 |ic arith|metic op|
|00001700| 65 72 61 74 69 6f 6e 20 | 73 75 63 68 20 61 73 0a |eration |such as.|
|00001710| 58 61 64 64 69 6e 67 2c | 20 73 75 62 74 72 61 63 |Xadding,| subtrac|
|00001720| 74 69 6e 67 2c 20 65 74 | 63 2e 20 20 54 68 69 73 |ting, et|c. This|
|00001730| 20 63 61 6e 20 62 65 63 | 6f 6d 65 20 63 75 6d 62 | can bec|ome cumb|
|00001740| 65 72 73 6f 6d 65 20 77 | 68 65 6e 20 74 68 65 20 |ersome w|hen the |
|00001750| 72 65 73 75 6c 74 0a 58 | 6f 66 20 61 20 63 6f 6d |result.X|of a com|
|00001760| 70 6c 69 63 61 74 65 64 | 20 65 78 70 72 65 73 73 |plicated| express|
|00001770| 69 6f 6e 20 69 73 20 64 | 65 73 69 72 65 64 2e 20 |ion is d|esired. |
|00001780| 20 54 68 65 72 65 66 6f | 72 65 2c 20 49 20 68 61 | Therefo|re, I ha|
|00001790| 76 65 20 61 64 64 65 64 | 20 61 0a 58 72 6f 75 74 |ve added| a.Xrout|
|000017a0| 69 6e 65 20 74 68 61 74 | 20 77 69 6c 6c 20 70 65 |ine that| will pe|
|000017b0| 72 66 6f 72 6d 20 61 20 | 73 65 72 69 65 73 20 6f |rform a |series o|
|000017c0| 66 20 6f 70 65 72 61 74 | 69 6f 6e 73 20 69 6e 20 |f operat|ions in |
|000017d0| 74 68 65 20 6d 61 6e 6e | 65 72 20 6f 66 20 61 6e |the mann|er of an|
|000017e0| 0a 58 52 50 4e 20 28 22 | 52 65 76 65 72 73 65 20 |.XRPN ("|Reverse |
|000017f0| 50 6f 6c 69 73 68 20 4e | 6f 74 61 74 69 6f 6e 22 |Polish N|otation"|
|00001800| 29 20 63 61 6c 63 75 6c | 61 74 6f 72 2e 20 20 53 |) calcul|ator. S|
|00001810| 65 65 20 74 68 65 20 72 | 6f 75 74 69 6e 65 20 27 |ee the r|outine '|
|00001820| 61 70 6d 43 61 6c 63 27 | 0a 58 28 62 65 6c 6f 77 |apmCalc'|.X(below|
|00001830| 29 20 66 6f 72 20 6d 6f | 72 65 20 64 65 74 61 69 |) for mo|re detai|
|00001840| 6c 73 2e 0a 58 0a 58 49 | 6e 20 6d 79 20 6f 72 69 |ls..X.XI|n my ori|
|00001850| 67 69 6e 61 6c 20 76 65 | 72 73 69 6f 6e 20 6f 66 |ginal ve|rsion of|
|00001860| 20 74 68 69 73 20 6c 69 | 62 72 61 72 79 2c 20 49 | this li|brary, I|
|00001870| 20 64 69 73 63 6f 76 65 | 72 65 64 20 74 68 61 74 | discove|red that|
|00001880| 20 61 20 67 72 65 61 74 | 20 64 65 61 6c 0a 58 6f | a great| deal.Xo|
|00001890| 66 20 73 79 73 74 65 6d | 20 6f 76 65 72 68 65 61 |f system| overhea|
|000018a0| 64 20 77 61 73 20 77 61 | 73 74 65 64 20 61 6c 6c |d was wa|sted all|
|000018b0| 6f 63 61 74 69 6e 67 20 | 61 6e 64 20 64 65 61 6c |ocating |and deal|
|000018c0| 6c 6f 63 61 74 69 6e 67 | 20 41 50 4d 20 76 61 6c |locating| APM val|
|000018d0| 75 65 73 2e 0a 58 53 6f | 2c 20 49 20 61 64 6f 70 |ues..XSo|, I adop|
|000018e0| 74 65 64 20 77 68 61 74 | 20 68 61 73 20 74 75 72 |ted what| has tur|
|000018f0| 6e 65 64 20 6f 75 74 20 | 74 6f 20 62 65 20 61 20 |ned out |to be a |
|00001900| 6e 6f 74 69 63 69 62 6c | 79 20 66 61 73 74 65 72 |noticibl|y faster|
|00001910| 20 61 6c 6c 6f 63 61 74 | 69 6f 6e 0a 58 73 63 68 | allocat|ion.Xsch|
|00001920| 65 6d 65 3a 20 6e 65 77 | 6c 79 20 61 6c 6c 6f 63 |eme: new|ly alloc|
|00001930| 61 74 65 64 20 41 50 4d | 20 76 61 6c 75 65 73 20 |ated APM| values |
|00001940| 61 72 65 20 73 74 6f 72 | 65 64 20 69 6e 20 61 20 |are stor|ed in a |
|00001950| 6c 69 73 74 2e 20 20 57 | 68 65 6e 20 74 68 65 0a |list. W|hen the.|
|00001960| 58 75 73 65 72 20 64 69 | 73 70 6f 73 65 73 20 6f |Xuser di|sposes o|
|00001970| 66 20 6f 6e 65 20 6f 66 | 20 74 68 65 73 65 2c 20 |f one of| these, |
|00001980| 69 74 20 69 73 6e 27 74 | 20 72 65 61 6c 6c 79 20 |it isn't| really |
|00001990| 66 72 65 65 64 3a 20 69 | 74 73 20 65 6e 74 72 79 |freed: i|ts entry|
|000019a0| 20 69 6e 20 74 68 65 0a | 58 6c 69 73 74 20 69 73 | in the.|Xlist is|
|000019b0| 20 6d 61 72 6b 65 64 20 | 61 73 20 75 6e 75 73 65 | marked |as unuse|
|000019c0| 64 2e 20 20 53 75 62 73 | 65 71 75 65 6e 74 20 61 |d. Subs|equent a|
|000019d0| 74 74 65 6d 70 74 73 20 | 74 6f 20 61 6c 6c 6f 63 |ttempts |to alloc|
|000019e0| 61 74 65 20 61 20 6e 65 | 77 20 41 50 4d 0a 58 76 |ate a ne|w APM.Xv|
|000019f0| 61 6c 75 65 20 77 69 6c | 6c 20 6d 61 6b 65 20 75 |alue wil|l make u|
|00001a00| 73 65 20 6f 66 20 61 6e | 79 20 65 78 69 73 74 69 |se of an|y existi|
|00001a10| 6e 67 20 65 6e 74 72 69 | 65 73 20 69 6e 20 74 68 |ng entri|es in th|
|00001a20| 69 73 20 6c 69 73 74 20 | 74 68 61 74 20 61 72 65 |is list |that are|
|00001a30| 0a 58 6d 61 72 6b 65 64 | 20 61 73 20 75 6e 75 73 |.Xmarked| as unus|
|00001a40| 65 64 20 69 6e 73 74 65 | 61 64 20 6f 66 20 61 6c |ed inste|ad of al|
|00001a50| 6c 6f 63 61 74 69 6e 67 | 20 61 20 6e 65 77 20 65 |locating| a new e|
|00001a60| 6e 74 72 79 2e 20 20 4f | 6e 6c 79 20 77 68 65 6e |ntry. O|nly when|
|00001a70| 20 74 68 65 72 65 0a 58 | 61 72 65 20 6e 6f 20 75 | there.X|are no u|
|00001a80| 6e 75 73 65 64 20 65 6e | 74 72 69 65 73 20 69 6e |nused en|tries in|
|00001a90| 20 74 68 65 20 6c 69 73 | 74 20 77 69 6c 6c 20 61 | the lis|t will a|
|00001aa0| 20 6e 65 77 20 65 6e 74 | 72 79 20 62 65 20 61 6c | new ent|ry be al|
|00001ab0| 6c 6f 63 61 74 65 64 2e | 0a 58 54 68 65 72 65 20 |located.|.XThere |
|00001ac0| 69 73 20 61 20 72 6f 75 | 74 69 6e 65 20 74 68 61 |is a rou|tine tha|
|00001ad0| 74 20 63 61 6e 20 62 65 | 20 63 61 6c 6c 65 64 20 |t can be| called |
|00001ae0| 77 68 69 63 68 20 77 69 | 6c 6c 20 70 65 72 66 6f |which wi|ll perfo|
|00001af0| 72 6d 20 61 20 67 61 72 | 62 61 67 65 0a 58 63 6f |rm a gar|bage.Xco|
|00001b00| 6c 6c 65 63 74 69 6f 6e | 3a 20 69 2e 65 2e 2c 20 |llection|: i.e., |
|00001b10| 69 74 20 61 63 74 75 61 | 6c 6c 79 20 66 72 65 65 |it actua|lly free|
|00001b20| 73 20 61 6c 6c 20 75 6e | 75 73 65 64 20 41 50 4d |s all un|used APM|
|00001b30| 20 65 6e 74 72 69 65 73 | 20 28 73 65 65 0a 58 27 | entries| (see.X'|
|00001b40| 61 70 6d 47 61 72 62 61 | 67 65 43 6f 6c 6c 65 63 |apmGarba|geCollec|
|00001b50| 74 27 2c 20 62 65 6c 6f | 77 29 2e 0a 58 0a 58 41 |t', belo|w)..X.XA|
|00001b60| 20 66 69 6c 65 20 63 61 | 6c 6c 65 64 20 61 70 6d | file ca|lled apm|
|00001b70| 2e 68 20 6d 75 73 74 20 | 62 65 20 69 6e 63 6c 75 |.h must |be inclu|
|00001b80| 64 65 64 20 69 6e 20 61 | 6c 6c 20 70 72 6f 67 72 |ded in a|ll progr|
|00001b90| 61 6d 73 20 74 68 61 74 | 20 75 73 65 20 74 68 65 |ams that| use the|
|00001ba0| 20 41 50 4d 0a 58 72 6f | 75 74 69 6e 65 73 2e 20 | APM.Xro|utines. |
|00001bb0| 20 49 74 20 64 65 66 69 | 6e 65 73 20 74 68 65 20 | It defi|nes the |
|00001bc0| 22 41 50 4d 22 20 64 61 | 74 61 20 74 79 70 65 2c |"APM" da|ta type,|
|00001bd0| 20 74 68 65 20 65 72 72 | 6f 72 20 63 6f 64 65 73 | the err|or codes|
|00001be0| 2c 20 74 68 65 0a 58 61 | 70 6d 5f 65 72 72 6e 6f |, the.Xa|pm_errno|
|00001bf0| 20 76 61 72 69 61 62 6c | 65 2c 20 61 6e 64 20 73 | variabl|e, and s|
|00001c00| 65 76 65 72 61 6c 20 6f | 74 68 65 72 20 74 68 69 |everal o|ther thi|
|00001c10| 6e 67 73 2e 0a 58 0a 58 | 54 68 69 73 20 73 6f 66 |ngs..X.X|This sof|
|00001c20| 74 77 61 72 65 20 77 61 | 73 20 77 72 69 74 74 65 |tware wa|s writte|
|00001c30| 6e 20 69 6e 20 61 73 20 | 70 6f 72 74 61 62 6c 65 |n in as |portable|
|00001c40| 20 61 20 6d 61 6e 6e 65 | 72 20 61 73 20 70 6f 73 | a manne|r as pos|
|00001c50| 73 69 62 6c 65 2e 20 20 | 49 20 68 61 76 65 0a 58 |sible. |I have.X|
|00001c60| 67 6f 74 74 65 6e 20 69 | 74 20 72 75 6e 6e 69 6e |gotten i|t runnin|
|00001c70| 67 20 73 75 63 63 65 73 | 73 66 75 6c 6c 79 20 75 |g succes|sfully u|
|00001c80| 6e 64 65 72 20 73 65 76 | 65 72 61 6c 20 65 6e 76 |nder sev|eral env|
|00001c90| 69 72 6f 6e 6d 65 6e 74 | 73 3a 20 6f 6e 20 61 20 |ironment|s: on a |
|00001ca0| 53 75 6e 0a 58 33 2f 78 | 78 78 20 75 73 69 6e 67 |Sun.X3/x|xx using|
|00001cb0| 20 53 75 6e 4f 53 20 33 | 2e 35 20 61 6e 64 20 34 | SunOS 3|.5 and 4|
|00001cc0| 2e 30 2c 20 6f 6e 20 61 | 6e 20 49 42 4d 20 52 54 |.0, on a|n IBM RT|
|00001cd0| 20 72 75 6e 6e 69 6e 67 | 20 75 6e 64 65 72 20 41 | running| under A|
|00001ce0| 49 58 2c 20 75 6e 64 65 | 72 0a 58 4d 53 44 4f 53 |IX, unde|r.XMSDOS|
|00001cf0| 20 6f 6e 20 61 6e 20 49 | 42 4d 20 50 43 20 75 73 | on an I|BM PC us|
|00001d00| 69 6e 67 20 4d 69 63 72 | 6f 73 6f 66 74 20 43 20 |ing Micr|osoft C |
|00001d10| 76 65 72 73 69 6f 6e 20 | 35 2e 31 20 61 6e 64 20 |version |5.1 and |
|00001d20| 54 75 72 62 6f 20 43 20 | 76 65 72 73 69 6f 6e 0a |Turbo C |version.|
|00001d30| 58 31 2e 35 20 28 6f 72 | 20 77 61 73 20 69 74 20 |X1.5 (or| was it |
|00001d40| 76 65 72 73 69 6f 6e 20 | 32 2e 30 3f 29 2e 20 20 |version |2.0?). |
|00001d50| 54 68 65 72 65 20 61 72 | 65 20 74 77 6f 20 6d 61 |There ar|e two ma|
|00001d60| 6b 65 66 69 6c 65 73 3a | 20 74 68 65 20 6f 6e 65 |kefiles:| the one|
|00001d70| 20 63 61 6c 6c 65 64 0a | 58 22 4d 61 6b 65 66 69 | called.|X"Makefi|
|00001d80| 6c 65 22 20 69 73 20 74 | 68 65 20 75 6e 69 78 20 |le" is t|he unix |
|00001d90| 76 65 72 73 69 6f 6e 20 | 2e 2e 2e 20 69 74 20 77 |version |... it w|
|00001da0| 6f 72 6b 73 20 75 6e 64 | 65 72 20 53 75 6e 4f 53 |orks und|er SunOS|
|00001db0| 20 33 2e 35 20 61 6e 64 | 20 49 0a 58 70 72 65 73 | 3.5 and| I.Xpres|
|00001dc0| 75 6d 65 20 69 74 20 77 | 6f 75 6c 64 20 62 65 20 |ume it w|ould be |
|00001dd0| 65 61 73 79 20 74 6f 20 | 61 6c 74 65 72 20 69 74 |easy to |alter it|
|00001de0| 20 74 6f 20 77 6f 72 6b | 20 75 6e 64 65 72 20 6f | to work| under o|
|00001df0| 74 68 65 72 20 75 6e 69 | 78 0a 58 65 6e 76 69 72 |ther uni|x.Xenvir|
|00001e00| 6f 6e 6d 65 6e 74 73 3b | 20 74 68 65 20 6f 6e 65 |onments;| the one|
|00001e10| 20 63 61 6c 6c 65 64 20 | 22 6d 61 6b 65 66 69 6c | called |"makefil|
|00001e20| 65 2e 6d 73 63 22 20 77 | 69 6c 6c 20 62 75 69 6c |e.msc" w|ill buil|
|00001e30| 64 20 74 68 65 20 6c 69 | 62 72 61 72 79 0a 58 75 |d the li|brary.Xu|
|00001e40| 6e 64 65 72 20 4d 53 44 | 4f 53 20 75 73 69 6e 67 |nder MSD|OS using|
|00001e50| 20 4d 69 63 72 6f 73 6f | 66 74 20 43 20 76 65 72 | Microso|ft C ver|
|00001e60| 73 69 6f 6e 20 35 2e 31 | 20 2e 2e 2e 20 69 74 20 |sion 5.1| ... it |
|00001e70| 69 73 20 6d 65 61 6e 74 | 20 74 6f 20 72 75 6e 20 |is meant| to run |
|00001e80| 77 69 74 68 0a 58 74 68 | 65 20 6d 61 6b 65 20 70 |with.Xth|e make p|
|00001e90| 72 6f 67 72 61 6d 20 22 | 50 43 2f 4d 41 4b 45 22 |rogram "|PC/MAKE"|
|00001ea0| 2e 0a 58 0a 58 49 27 6d | 20 73 75 72 65 20 74 68 |..X.XI'm| sure th|
|00001eb0| 61 74 20 73 6f 6d 65 20 | 6f 66 20 79 6f 75 20 77 |at some |of you w|
|00001ec0| 69 6c 6c 20 66 69 6e 64 | 20 77 61 79 73 20 6f 66 |ill find| ways of|
|00001ed0| 20 65 6e 68 61 6e 63 69 | 6e 67 20 61 6e 64 20 73 | enhanci|ng and s|
|00001ee0| 70 65 65 64 69 6e 67 20 | 75 70 0a 58 74 68 65 20 |peeding |up.Xthe |
|00001ef0| 72 6f 75 74 69 6e 65 73 | 20 69 6e 20 74 68 69 73 |routines| in this|
|00001f00| 20 6c 69 62 72 61 72 79 | 2e 20 20 54 69 6d 65 20 | library|. Time |
|00001f10| 70 65 72 6d 69 74 74 69 | 6e 67 2c 20 49 20 77 69 |permitti|ng, I wi|
|00001f20| 6c 6c 20 62 65 20 64 6f | 69 6e 67 20 74 68 61 74 |ll be do|ing that|
|00001f30| 0a 58 61 73 20 77 65 6c | 6c 2e 20 20 49 20 75 72 |.Xas wel|l. I ur|
|00001f40| 67 65 20 79 6f 75 20 74 | 6f 20 70 6f 73 74 20 79 |ge you t|o post y|
|00001f50| 6f 75 72 20 62 75 67 20 | 66 69 78 65 73 20 61 6e |our bug |fixes an|
|00001f60| 64 20 63 68 61 6e 67 65 | 73 20 74 6f 20 74 68 65 |d change|s to the|
|00001f70| 20 6e 65 74 20 61 6e 64 | 0a 58 6d 61 69 6c 20 74 | net and|.Xmail t|
|00001f80| 68 65 6d 20 74 6f 20 6d | 65 20 61 74 20 6d 79 20 |hem to m|e at my |
|00001f90| 61 64 64 72 65 73 73 20 | 62 65 6c 6f 77 2c 20 73 |address |below, s|
|00001fa0| 6f 20 74 68 65 79 20 6d | 69 67 68 74 20 62 65 20 |o they m|ight be |
|00001fb0| 69 6e 63 6f 72 70 6f 72 | 61 74 65 64 0a 58 69 6e |incorpor|ated.Xin|
|00001fc0| 74 6f 20 61 20 6c 61 74 | 65 72 20 76 65 72 73 69 |to a lat|er versi|
|00001fd0| 6f 6e 20 6f 66 20 74 68 | 69 73 20 6c 69 62 72 61 |on of th|is libra|
|00001fe0| 72 79 2e 20 20 53 6f 6d | 65 20 73 75 67 67 65 73 |ry. Som|e sugges|
|00001ff0| 74 65 64 20 61 72 65 61 | 73 20 6f 66 0a 58 65 6e |ted area|s of.Xen|
|00002000| 68 61 6e 63 65 6d 65 6e | 74 20 61 6e 64 20 6f 70 |hancemen|t and op|
|00002010| 74 69 6d 69 7a 61 74 69 | 6f 6e 20 61 72 65 3a 0a |timizati|on are:.|
|00002020| 58 0a 58 31 29 09 53 6f | 6d 65 68 6f 77 20 73 70 |X.X1).So|mehow sp|
|00002030| 65 65 64 69 6e 67 20 75 | 70 20 74 68 65 20 6d 65 |eeding u|p the me|
|00002040| 6d 6f 72 79 20 61 6c 6c | 6f 63 61 74 69 6f 6e 20 |mory all|ocation |
|00002050| 73 63 68 65 6d 65 2e 0a | 58 0a 58 32 29 09 53 6f |scheme..|X.X2).So|
|00002060| 6d 65 20 73 6f 72 74 20 | 6f 66 20 66 6c 6f 61 74 |me sort |of float|
|00002070| 69 6e 67 2d 70 6f 69 6e | 74 2f 41 50 4d 20 63 6f |ing-poin|t/APM co|
|00002080| 6e 76 65 72 73 69 6f 6e | 2e 20 20 49 20 6c 65 66 |nversion|. I lef|
|00002090| 74 20 74 68 69 73 20 6f | 75 74 0a 58 09 62 65 63 |t this o|ut.X.bec|
|000020a0| 61 75 73 65 20 6f 66 20 | 74 68 65 20 77 69 64 65 |ause of |the wide|
|000020b0| 6c 79 20 76 61 72 79 69 | 6e 67 20 66 6c 6f 61 74 |ly varyi|ng float|
|000020c0| 69 6e 67 2d 70 6f 69 6e | 74 20 66 6f 72 6d 61 74 |ing-poin|t format|
|000020d0| 73 20 74 68 61 74 0a 58 | 09 65 78 69 73 74 20 6f |s that.X|.exist o|
|000020e0| 6e 20 74 68 65 20 76 61 | 72 69 6f 75 73 20 6d 61 |n the va|rious ma|
|000020f0| 63 68 69 6e 65 73 20 74 | 68 65 73 65 20 72 6f 75 |chines t|hese rou|
|00002100| 74 69 6e 65 73 20 63 61 | 6e 20 61 6e 64 20 6d 69 |tines ca|n and mi|
|00002110| 67 68 74 20 72 75 6e 0a | 58 09 6f 6e 2c 20 61 6e |ght run.|X.on, an|
|00002120| 64 20 62 65 63 61 75 73 | 65 20 49 20 69 6e 74 65 |d becaus|e I inte|
|00002130| 6e 64 65 64 20 41 50 4d | 20 74 6f 20 2a 72 65 70 |nded APM| to *rep|
|00002140| 6c 61 63 65 2a 20 66 6c | 6f 61 74 69 6e 67 2d 70 |lace* fl|oating-p|
|00002150| 6f 69 6e 74 2c 0a 58 09 | 6e 6f 74 20 74 6f 20 77 |oint,.X.|not to w|
|00002160| 6f 72 6b 20 69 6e 20 63 | 6f 6e 6a 75 6e 63 74 69 |ork in c|onjuncti|
|00002170| 6f 6e 20 77 69 74 68 20 | 69 74 2e 0a 58 0a 58 33 |on with |it..X.X3|
|00002180| 29 09 42 61 73 65 20 63 | 6f 6e 76 65 72 73 69 6f |).Base c|onversio|
|00002190| 6e 2e 0a 58 0a 58 34 29 | 09 52 6f 6f 74 73 2c 20 |n..X.X4)|.Roots, |
|000021a0| 70 6f 77 65 72 73 2c 20 | 6c 6f 67 61 72 69 74 68 |powers, |logarith|
|000021b0| 6d 73 2c 20 74 72 69 67 | 20 66 75 6e 63 74 69 6f |ms, trig| functio|
|000021c0| 6e 73 2c 20 65 78 70 6f | 6e 65 6e 74 69 61 6c 20 |ns, expo|nential |
|000021d0| 66 75 6e 63 74 69 6f 6e | 73 2c 0a 58 09 65 74 63 |function|s,.X.etc|
|000021e0| 2e 0a 58 0a 58 35 29 20 | 20 09 4d 6f 72 65 20 70 |..X.X5) | .More p|
|000021f0| 72 6f 64 75 63 74 69 6f | 6e 73 20 69 6e 20 74 68 |roductio|ns in th|
|00002200| 65 20 6d 61 6b 65 66 69 | 6c 65 73 20 28 22 69 6e |e makefi|les ("in|
|00002210| 73 74 61 6c 6c 22 2c 20 | 22 72 64 69 73 74 22 2c |stall", |"rdist",|
|00002220| 20 65 74 63 2e 29 2e 0a | 58 0a 58 36 29 20 20 09 | etc.)..|X.X6) .|
|00002230| 41 20 66 61 6e 63 79 20 | 69 6e 73 74 61 6c 6c 61 |A fancy |installa|
|00002240| 74 69 6f 6e 20 73 63 72 | 69 70 74 2e 0a 58 0a 58 |tion scr|ipt..X.X|
|00002250| 37 29 09 57 72 69 74 69 | 6e 67 20 61 20 6d 61 6e |7).Writi|ng a man|
|00002260| 20 70 61 67 65 20 66 6f | 72 20 61 6c 6c 20 74 68 | page fo|r all th|
|00002270| 69 73 2e 0a 40 5c 45 4e | 44 5f 4f 46 5f 46 49 4c |is..@\EN|D_OF_FIL|
|00002280| 45 5f 52 45 41 44 4d 45 | 0a 65 6c 73 65 0a 20 20 |E_README|.else. |
|00002290| 65 63 68 6f 20 22 73 68 | 61 72 3a 20 57 69 6c 6c |echo "sh|ar: Will|
|000022a0| 20 6e 6f 74 20 6f 76 65 | 72 20 77 72 69 74 65 20 | not ove|r write |
|000022b0| 52 45 41 44 4d 45 22 0a | 66 69 0a 69 66 20 60 74 |README".|fi.if `t|
|000022c0| 65 73 74 20 21 20 2d 73 | 20 46 55 4e 43 54 49 4f |est ! -s| FUNCTIO|
|000022d0| 4e 53 60 0a 74 68 65 6e | 0a 65 63 68 6f 20 22 78 |NS`.then|.echo "x|
|000022e0| 20 2d 20 46 55 4e 43 54 | 49 4f 4e 53 22 0a 73 65 | - FUNCT|IONS".se|
|000022f0| 64 20 27 73 2f 5e 58 2f | 2f 27 20 3e 20 46 55 4e |d 's/^X/|/' > FUN|
|00002300| 43 54 49 4f 4e 53 20 3c | 3c 20 27 40 5c 45 4e 44 |CTIONS <|< '@\END|
|00002310| 5f 4f 46 5f 46 49 4c 45 | 5f 46 55 4e 43 54 49 4f |_OF_FILE|_FUNCTIO|
|00002320| 4e 53 27 0a 58 41 50 4d | 0a 58 61 70 6d 49 6e 69 |NS'.XAPM|.XapmIni|
|00002330| 74 28 69 6e 69 74 2c 20 | 73 63 61 6c 65 5f 66 61 |t(init, |scale_fa|
|00002340| 63 74 6f 72 2c 20 62 61 | 73 65 29 0a 58 6c 6f 6e |ctor, ba|se).Xlon|
|00002350| 67 20 69 6e 69 74 3b 0a | 58 69 6e 74 20 73 63 61 |g init;.|Xint sca|
|00002360| 6c 65 5f 66 61 63 74 6f | 72 3b 0a 58 73 68 6f 72 |le_facto|r;.Xshor|
|00002370| 74 20 62 61 73 65 3b 0a | 58 7b 7d 0a 58 20 20 54 |t base;.|X{}.X T|
|00002380| 68 69 73 20 72 6f 75 74 | 69 6e 65 20 69 6e 69 74 |his rout|ine init|
|00002390| 69 61 6c 69 7a 65 73 20 | 61 20 6e 65 77 20 41 50 |ializes |a new AP|
|000023a0| 4d 20 76 61 6c 75 65 2e | 20 20 54 68 65 20 27 69 |M value.| The 'i|
|000023b0| 6e 69 74 27 20 70 61 72 | 61 6d 65 74 65 72 20 69 |nit' par|ameter i|
|000023c0| 73 20 61 20 6c 6f 6e 67 | 0a 58 20 20 69 6e 74 65 |s a long|.X inte|
|000023d0| 67 65 72 20 74 68 61 74 | 20 72 65 70 72 65 73 65 |ger that| represe|
|000023e0| 6e 74 73 20 69 74 73 20 | 69 6e 69 74 69 61 6c 20 |nts its |initial |
|000023f0| 76 61 6c 75 65 2c 20 74 | 68 65 20 27 73 63 61 6c |value, t|he 'scal|
|00002400| 65 5f 66 61 63 74 6f 72 | 27 20 76 61 72 69 61 62 |e_factor|' variab|
|00002410| 6c 65 0a 58 20 20 69 6e | 64 69 63 61 74 65 73 20 |le.X in|dicates |
|00002420| 68 6f 77 20 74 68 69 73 | 20 69 6e 69 74 69 61 6c |how this| initial|
|00002430| 20 76 61 6c 75 65 20 73 | 68 6f 75 6c 64 20 62 65 | value s|hould be|
|00002440| 20 73 63 61 6c 65 64 2c | 20 61 6e 64 20 27 62 61 | scaled,| and 'ba|
|00002450| 73 65 27 20 69 73 20 74 | 68 65 20 62 61 73 65 20 |se' is t|he base |
|00002460| 6f 66 0a 58 20 20 74 68 | 65 20 69 6e 69 74 69 61 |of.X th|e initia|
|00002470| 6c 20 76 61 6c 75 65 2e | 20 20 4e 6f 74 65 20 74 |l value.| Note t|
|00002480| 68 61 74 20 74 68 65 20 | 41 50 4d 20 76 61 6c 75 |hat the |APM valu|
|00002490| 65 20 72 65 74 75 72 6e | 65 64 20 62 79 20 74 68 |e return|ed by th|
|000024a0| 69 73 20 72 6f 75 74 69 | 6e 65 20 69 73 0a 58 20 |is routi|ne is.X |
|000024b0| 20 6e 6f 72 6d 61 6c 6c | 79 20 61 20 72 65 63 6c | normall|y a recl|
|000024c0| 61 69 6d 65 64 20 41 50 | 4d 20 76 61 6c 75 65 20 |aimed AP|M value |
|000024d0| 74 68 61 74 20 68 61 73 | 20 62 65 65 6e 20 70 72 |that has| been pr|
|000024e0| 65 76 69 6f 75 73 6c 79 | 20 64 69 73 70 6f 73 65 |eviously| dispose|
|000024f0| 64 20 6f 66 20 76 69 61 | 0a 58 20 20 61 70 6d 44 |d of via|.X apmD|
|00002500| 69 73 70 6f 73 65 28 29 | 3b 20 6f 6e 6c 79 20 69 |ispose()|; only i|
|00002510| 66 20 74 68 65 72 65 20 | 61 72 65 20 6e 6f 20 70 |f there |are no p|
|00002520| 72 65 76 69 6f 75 73 20 | 76 61 6c 75 65 73 20 74 |revious |values t|
|00002530| 6f 20 62 65 20 72 65 63 | 6c 61 69 6d 65 64 20 77 |o be rec|laimed w|
|00002540| 69 6c 6c 20 74 68 69 73 | 0a 58 20 20 72 6f 75 74 |ill this|.X rout|
|00002550| 69 6e 65 20 61 6c 6c 6f | 63 61 74 65 20 61 20 66 |ine allo|cate a f|
|00002560| 72 65 73 68 20 41 50 4d | 20 76 61 6c 75 65 20 28 |resh APM| value (|
|00002570| 73 65 65 20 61 6c 73 6f | 20 74 68 65 20 61 70 6d |see also| the apm|
|00002580| 47 61 72 62 61 67 65 43 | 6f 6c 6c 65 63 74 28 29 |GarbageC|ollect()|
|00002590| 0a 58 20 20 72 6f 75 74 | 69 6e 65 29 2e 0a 58 0a |.X rout|ine)..X.|
|000025a0| 58 20 20 42 61 73 65 73 | 20 63 61 6e 20 62 65 20 |X Bases| can be |
|000025b0| 32 20 2d 20 33 36 2c 20 | 31 30 30 30 30 2c 20 6f |2 - 36, |10000, o|
|000025c0| 72 20 30 2c 20 77 68 65 | 72 65 20 30 20 64 65 66 |r 0, whe|re 0 def|
|000025d0| 61 75 6c 74 73 20 74 6f | 20 62 61 73 65 20 31 30 |aults to| base 10|
|000025e0| 30 30 30 2e 0a 58 0a 58 | 20 20 49 66 20 74 68 65 |000..X.X| If the|
|000025f0| 20 63 61 6c 6c 20 66 61 | 69 6c 73 2c 20 69 74 20 | call fa|ils, it |
|00002600| 77 69 6c 6c 20 72 65 74 | 75 72 6e 20 28 41 50 4d |will ret|urn (APM|
|00002610| 29 4e 55 4c 4c 20 61 6e | 64 20 27 61 70 6d 5f 65 |)NULL an|d 'apm_e|
|00002620| 72 72 6e 6f 27 20 77 69 | 6c 6c 20 63 6f 6e 74 61 |rrno' wi|ll conta|
|00002630| 69 6e 20 61 0a 58 20 20 | 6d 65 61 6e 69 6e 67 66 |in a.X |meaningf|
|00002640| 75 6c 20 72 65 73 75 6c | 74 2e 20 20 4f 74 68 65 |ul resul|t. Othe|
|00002650| 72 77 69 73 65 2c 20 61 | 20 6e 65 77 20 41 50 4d |rwise, a| new APM|
|00002660| 20 76 61 6c 75 65 20 77 | 69 6c 6c 20 62 65 20 69 | value w|ill be i|
|00002670| 6e 69 74 69 61 6c 69 7a | 65 64 2e 0a 58 0a 58 20 |nitializ|ed..X.X |
|00002680| 20 46 6f 72 20 65 78 61 | 6d 70 6c 65 2c 20 61 73 | For exa|mple, as|
|00002690| 73 75 6d 65 20 74 68 61 | 74 20 77 65 20 77 61 6e |sume tha|t we wan|
|000026a0| 74 20 74 6f 20 69 6e 69 | 74 69 61 6c 69 7a 65 20 |t to ini|tialize |
|000026b0| 74 77 6f 20 41 50 4d 20 | 76 61 6c 75 65 73 20 69 |two APM |values i|
|000026c0| 6e 20 62 61 73 65 20 31 | 30 30 30 30 2c 0a 58 20 |n base 1|0000,.X |
|000026d0| 20 74 68 65 20 66 69 72 | 73 74 20 74 6f 20 31 2e | the fir|st to 1.|
|000026e0| 32 33 34 35 36 20 61 6e | 64 20 74 68 65 20 73 65 |23456 an|d the se|
|000026f0| 63 6f 6e 64 20 74 6f 20 | 31 20 45 32 30 20 28 22 |cond to |1 E20 ("|
|00002700| 6f 6e 65 20 74 69 6d 65 | 73 20 31 30 20 74 6f 20 |one time|s 10 to |
|00002710| 74 68 65 20 32 30 74 68 | 0a 58 20 20 70 6f 77 65 |the 20th|.X powe|
|00002720| 72 22 29 3a 0a 58 0a 58 | 20 20 20 20 20 20 41 50 |r"):.X.X| AP|
|00002730| 4d 20 61 70 6d 5f 31 20 | 3d 20 61 70 6d 49 6e 69 |M apm_1 |= apmIni|
|00002740| 74 28 31 32 33 34 35 36 | 4c 2c 20 2d 35 2c 20 30 |t(123456|L, -5, 0|
|00002750| 29 3b 0a 58 20 20 20 20 | 20 20 41 50 4d 20 61 70 |);.X | APM ap|
|00002760| 6d 5f 32 20 3d 20 61 70 | 6d 49 6e 69 74 28 31 4c |m_2 = ap|mInit(1L|
|00002770| 2c 20 32 30 2c 20 30 29 | 3b 0a 58 0a 58 20 20 41 |, 20, 0)|;.X.X A|
|00002780| 73 20 61 20 63 6f 6e 76 | 65 6e 69 65 6e 63 65 2c |s a conv|enience,|
|00002790| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 6d | the fol|lowing m|
|000027a0| 61 63 72 6f 20 69 73 20 | 64 65 66 69 6e 65 64 20 |acro is |defined |
|000027b0| 69 6e 20 61 70 6d 2e 68 | 3a 0a 58 0a 58 20 20 20 |in apm.h|:.X.X |
|000027c0| 20 20 20 23 64 65 66 69 | 6e 65 20 61 70 6d 4e 65 | #defi|ne apmNe|
|000027d0| 77 28 42 41 53 45 29 20 | 20 20 20 61 70 6d 49 6e |w(BASE) | apmIn|
|000027e0| 69 74 28 30 4c 2c 20 30 | 2c 20 28 42 41 53 45 29 |it(0L, 0|, (BASE)|
|000027f0| 29 0a 58 0a 58 69 6e 74 | 0a 58 61 70 6d 44 69 73 |).X.Xint|.XapmDis|
|00002800| 70 6f 73 65 28 61 70 6d | 29 0a 58 41 50 4d 20 61 |pose(apm|).XAPM a|
|00002810| 70 6d 3b 0a 58 7b 7d 0a | 58 20 20 54 68 69 73 20 |pm;.X{}.|X This |
|00002820| 72 6f 75 74 69 6e 65 20 | 64 69 73 70 6f 73 65 73 |routine |disposes|
|00002830| 20 6f 66 20 61 20 41 50 | 4d 20 76 61 6c 75 65 20 | of a AP|M value |
|00002840| 27 61 70 6d 27 20 62 79 | 20 72 65 74 75 72 6e 69 |'apm' by| returni|
|00002850| 6e 67 20 69 74 20 74 6f | 20 74 68 65 20 6c 69 73 |ng it to| the lis|
|00002860| 74 20 6f 66 0a 58 20 20 | 75 6e 75 73 65 64 20 41 |t of.X |unused A|
|00002870| 50 4d 20 76 61 6c 75 65 | 73 20 28 73 65 65 20 61 |PM value|s (see a|
|00002880| 6c 73 6f 20 74 68 65 20 | 61 70 6d 47 61 72 62 61 |lso the |apmGarba|
|00002890| 67 65 43 6f 6c 6c 65 63 | 74 28 29 20 72 6f 75 74 |geCollec|t() rout|
|000028a0| 69 6e 65 29 2e 20 20 49 | 74 20 72 65 74 75 72 6e |ine). I|t return|
|000028b0| 73 0a 58 20 20 61 6e 20 | 61 70 70 72 6f 70 72 69 |s.X an |appropri|
|000028c0| 61 74 65 20 73 74 61 74 | 75 73 20 77 68 69 63 68 |ate stat|us which|
|000028d0| 20 69 73 20 61 6c 73 6f | 20 70 75 74 20 69 6e 74 | is also| put int|
|000028e0| 6f 20 27 61 70 6d 5f 65 | 72 72 6e 6f 27 2e 0a 58 |o 'apm_e|rrno'..X|
|000028f0| 0a 58 69 6e 74 0a 58 61 | 70 6d 47 61 72 62 61 67 |.Xint.Xa|pmGarbag|
|00002900| 65 43 6f 6c 6c 65 63 74 | 28 29 0a 58 7b 7d 0a 58 |eCollect|().X{}.X|
|00002910| 20 20 57 68 65 6e 20 41 | 50 4d 20 76 61 6c 75 65 | When A|PM value|
|00002920| 73 20 61 72 65 20 64 69 | 73 70 6f 73 65 64 20 6f |s are di|sposed o|
|00002930| 66 2c 20 74 68 65 79 20 | 72 65 6d 61 69 6e 20 61 |f, they |remain a|
|00002940| 6c 6c 6f 63 61 74 65 64 | 2e 20 20 53 75 62 73 65 |llocated|. Subse|
|00002950| 71 75 65 6e 74 20 63 61 | 6c 6c 73 20 74 6f 0a 58 |quent ca|lls to.X|
|00002960| 20 20 61 70 6d 49 6e 69 | 74 28 29 20 6d 61 79 20 | apmIni|t() may |
|00002970| 74 68 65 6e 20 72 65 74 | 75 72 6e 20 61 20 70 72 |then ret|urn a pr|
|00002980| 65 76 69 6f 75 73 6c 79 | 20 61 6c 6c 6f 63 61 74 |eviously| allocat|
|00002990| 65 64 20 62 75 74 20 64 | 69 73 70 6f 73 65 64 20 |ed but d|isposed |
|000029a0| 41 50 4d 20 76 61 6c 75 | 65 2e 0a 58 20 20 54 68 |APM valu|e..X Th|
|000029b0| 69 73 20 69 73 20 64 6f | 6e 65 20 66 6f 72 20 73 |is is do|ne for s|
|000029c0| 70 65 65 64 20 63 6f 6e | 73 69 64 65 72 61 74 69 |peed con|siderati|
|000029d0| 6f 6e 73 2c 20 62 75 74 | 20 61 66 74 65 72 20 61 |ons, but| after a|
|000029e0| 20 77 68 69 6c 65 20 74 | 68 65 72 65 20 6d 61 79 | while t|here may|
|000029f0| 20 62 65 20 6c 6f 74 73 | 20 6f 66 0a 58 20 20 74 | be lots| of.X t|
|00002a00| 68 65 73 65 20 75 6e 75 | 73 65 64 20 41 50 4d 20 |hese unu|sed APM |
|00002a10| 76 61 6c 75 65 73 20 6c | 79 69 6e 67 20 61 72 6f |values l|ying aro|
|00002a20| 75 6e 64 2e 20 20 54 68 | 69 73 20 72 6f 75 74 69 |und. Th|is routi|
|00002a30| 6e 65 20 72 65 63 6c 61 | 69 6d 73 20 74 68 65 20 |ne recla|ims the |
|00002a40| 73 70 61 63 65 20 74 61 | 6b 65 6e 0a 58 20 20 75 |space ta|ken.X u|
|00002a50| 70 20 62 79 20 74 68 65 | 73 65 20 75 6e 75 73 65 |p by the|se unuse|
|00002a60| 64 20 41 50 4d 20 76 61 | 6c 75 65 73 20 28 69 74 |d APM va|lues (it|
|00002a70| 20 66 72 65 65 73 20 74 | 68 65 6d 29 2e 20 20 49 | frees t|hem). I|
|00002a80| 74 20 72 65 74 75 72 6e | 73 20 61 6e 20 61 70 70 |t return|s an app|
|00002a90| 72 6f 70 72 69 61 74 65 | 0a 58 20 20 73 74 61 74 |ropriate|.X stat|
|00002aa0| 75 73 20 77 68 69 63 68 | 20 69 73 20 61 6c 73 6f |us which| is also|
|00002ab0| 20 70 75 74 20 69 6e 74 | 6f 20 27 61 70 6d 5f 65 | put int|o 'apm_e|
|00002ac0| 72 72 6e 6f 27 2e 0a 58 | 0a 58 69 6e 74 0a 58 61 |rrno'..X|.Xint.Xa|
|00002ad0| 70 6d 41 64 64 28 72 65 | 73 75 6c 74 2c 20 61 70 |pmAdd(re|sult, ap|
|00002ae0| 6d 31 2c 20 61 70 6d 32 | 29 0a 58 41 50 4d 20 72 |m1, apm2|).XAPM r|
|00002af0| 65 73 75 6c 74 3b 0a 58 | 41 50 4d 20 61 70 6d 31 |esult;.X|APM apm1|
|00002b00| 3b 0a 58 41 50 4d 20 61 | 70 6d 32 3b 0a 58 7b 7d |;.XAPM a|pm2;.X{}|
|00002b10| 0a 58 20 20 54 68 69 73 | 20 72 6f 75 74 69 6e 65 |.X This| routine|
|00002b20| 20 61 64 64 73 20 27 61 | 70 6d 31 27 20 61 6e 64 | adds 'a|pm1' and|
|00002b30| 20 27 61 70 6d 32 27 2c | 20 70 75 74 74 69 6e 67 | 'apm2',| putting|
|00002b40| 20 74 68 65 20 73 75 6d | 20 69 6e 74 6f 20 27 72 | the sum| into 'r|
|00002b50| 65 73 75 6c 74 27 2c 20 | 77 68 6f 73 65 0a 58 20 |esult', |whose.X |
|00002b60| 20 70 72 65 76 69 6f 75 | 73 20 76 61 6c 75 65 20 | previou|s value |
|00002b70| 69 73 20 64 65 73 74 72 | 6f 79 65 64 2e 20 20 4e |is destr|oyed. N|
|00002b80| 6f 74 65 20 74 68 61 74 | 20 61 6c 6c 20 74 68 72 |ote that| all thr|
|00002b90| 65 65 20 70 61 72 61 6d | 65 74 65 72 73 20 6d 75 |ee param|eters mu|
|00002ba0| 73 74 20 68 61 76 65 20 | 62 65 65 6e 0a 58 20 20 |st have |been.X |
|00002bb0| 70 72 65 76 69 6f 75 73 | 6c 79 20 69 6e 69 74 69 |previous|ly initi|
|00002bc0| 61 6c 69 7a 65 64 20 76 | 69 61 20 61 70 6d 49 6e |alized v|ia apmIn|
|00002bd0| 69 74 28 29 2e 0a 58 0a | 58 20 20 54 68 65 20 27 |it()..X.|X The '|
|00002be0| 72 65 73 75 6c 74 27 20 | 70 61 72 61 6d 65 74 65 |result' |paramete|
|00002bf0| 72 20 63 61 6e 6e 6f 74 | 20 62 65 20 6f 6e 65 20 |r cannot| be one |
|00002c00| 6f 66 20 74 68 65 20 6f | 74 68 65 72 20 41 50 4d |of the o|ther APM|
|00002c10| 20 70 61 72 61 6d 65 74 | 65 72 73 2e 0a 58 0a 58 | paramet|ers..X.X|
|00002c20| 20 20 54 68 65 20 72 65 | 74 75 72 6e 20 63 6f 64 | The re|turn cod|
|00002c30| 65 20 61 6e 64 20 74 68 | 65 20 27 61 70 6d 5f 65 |e and th|e 'apm_e|
|00002c40| 72 72 6f 72 27 20 76 61 | 72 69 61 62 6c 65 20 72 |rror' va|riable r|
|00002c50| 65 66 6c 65 63 74 20 74 | 68 65 20 73 74 61 74 75 |eflect t|he statu|
|00002c60| 73 20 6f 66 20 74 68 69 | 73 0a 58 20 20 66 75 6e |s of thi|s.X fun|
|00002c70| 63 74 69 6f 6e 2e 0a 58 | 0a 58 69 6e 74 0a 58 61 |ction..X|.Xint.Xa|
|00002c80| 70 6d 53 75 62 74 72 61 | 63 74 28 72 65 73 75 6c |pmSubtra|ct(resul|
|00002c90| 74 2c 20 61 70 6d 31 2c | 20 61 70 6d 32 29 0a 58 |t, apm1,| apm2).X|
|00002ca0| 41 50 4d 20 72 65 73 75 | 6c 74 3b 0a 58 41 50 4d |APM resu|lt;.XAPM|
|00002cb0| 20 61 70 6d 31 3b 0a 58 | 41 50 4d 20 61 70 6d 32 | apm1;.X|APM apm2|
|00002cc0| 3b 0a 58 7b 7d 0a 58 20 | 20 54 68 69 73 20 72 6f |;.X{}.X | This ro|
|00002cd0| 75 74 69 6e 65 20 73 75 | 62 74 72 61 63 74 73 20 |utine su|btracts |
|00002ce0| 27 61 70 6d 32 27 20 66 | 72 6f 6d 20 27 61 70 6d |'apm2' f|rom 'apm|
|00002cf0| 31 27 2c 20 70 75 74 74 | 69 6e 67 20 74 68 65 20 |1', putt|ing the |
|00002d00| 64 69 66 66 65 72 65 6e | 63 65 20 69 6e 74 6f 0a |differen|ce into.|
|00002d10| 58 20 20 27 72 65 73 75 | 6c 74 27 2c 20 77 68 6f |X 'resu|lt', who|
|00002d20| 73 65 20 70 72 65 76 69 | 6f 75 73 20 76 61 6c 75 |se previ|ous valu|
|00002d30| 65 20 69 73 20 64 65 73 | 74 72 6f 79 65 64 2e 20 |e is des|troyed. |
|00002d40| 20 4e 6f 74 65 20 74 68 | 61 74 20 61 6c 6c 20 74 | Note th|at all t|
|00002d50| 68 72 65 65 20 70 61 72 | 61 6d 65 74 65 72 73 0a |hree par|ameters.|
|00002d60| 58 20 20 6d 75 73 74 20 | 68 61 76 65 20 62 65 65 |X must |have bee|
|00002d70| 6e 20 70 72 65 76 69 6f | 75 73 6c 79 20 69 6e 69 |n previo|usly ini|
|00002d80| 74 69 61 6c 69 7a 65 64 | 20 76 69 61 20 61 70 6d |tialized| via apm|
|00002d90| 49 6e 69 74 28 29 2e 0a | 58 0a 58 20 20 54 68 65 |Init()..|X.X The|
|00002da0| 20 27 72 65 73 75 6c 74 | 27 20 70 61 72 61 6d 65 | 'result|' parame|
|00002db0| 74 65 72 20 63 61 6e 6e | 6f 74 20 62 65 20 6f 6e |ter cann|ot be on|
|00002dc0| 65 20 6f 66 20 74 68 65 | 20 6f 74 68 65 72 20 41 |e of the| other A|
|00002dd0| 50 4d 20 70 61 72 61 6d | 65 74 65 72 73 2e 0a 58 |PM param|eters..X|
|00002de0| 0a 58 20 20 54 68 65 20 | 72 65 74 75 72 6e 20 63 |.X The |return c|
|00002df0| 6f 64 65 20 61 6e 64 20 | 74 68 65 20 27 61 70 6d |ode and |the 'apm|
|00002e00| 5f 65 72 72 6e 6f 27 20 | 76 61 72 69 61 62 6c 65 |_errno' |variable|
|00002e10| 20 72 65 66 6c 65 63 74 | 20 74 68 65 20 73 74 61 | reflect| the sta|
|00002e20| 74 75 73 20 6f 66 20 74 | 68 69 73 0a 58 20 20 66 |tus of t|his.X f|
|00002e30| 75 6e 63 74 69 6f 6e 2e | 0a 58 0a 58 69 6e 74 0a |unction.|.X.Xint.|
|00002e40| 58 61 70 6d 4d 75 6c 74 | 69 70 6c 79 28 72 65 73 |XapmMult|iply(res|
|00002e50| 75 6c 74 2c 20 61 70 6d | 31 2c 20 61 70 6d 32 29 |ult, apm|1, apm2)|
|00002e60| 0a 58 41 50 4d 20 72 65 | 73 75 6c 74 3b 0a 58 41 |.XAPM re|sult;.XA|
|00002e70| 50 4d 20 61 70 6d 31 3b | 0a 58 41 50 4d 20 61 70 |PM apm1;|.XAPM ap|
|00002e80| 6d 32 3b 0a 58 7b 7d 0a | 58 20 20 54 68 69 73 20 |m2;.X{}.|X This |
|00002e90| 72 6f 75 74 69 6e 65 20 | 6d 75 6c 74 69 70 6c 69 |routine |multipli|
|00002ea0| 65 73 20 27 61 70 6d 31 | 27 20 61 6e 64 20 27 61 |es 'apm1|' and 'a|
|00002eb0| 70 6d 32 27 2c 20 70 75 | 74 74 69 6e 67 20 74 68 |pm2', pu|tting th|
|00002ec0| 65 20 70 72 6f 64 75 63 | 74 20 69 6e 74 6f 20 27 |e produc|t into '|
|00002ed0| 72 65 73 75 6c 74 27 2c | 0a 58 20 20 77 68 6f 73 |result',|.X whos|
|00002ee0| 65 20 70 72 65 76 69 6f | 75 73 20 76 61 6c 75 65 |e previo|us value|
|00002ef0| 20 69 73 20 64 65 73 74 | 72 6f 79 65 64 2e 20 20 | is dest|royed. |
|00002f00| 4e 6f 74 65 20 74 68 61 | 74 20 61 6c 6c 20 74 68 |Note tha|t all th|
|00002f10| 72 65 65 20 70 61 72 61 | 6d 65 74 65 72 73 20 6d |ree para|meters m|
|00002f20| 75 73 74 20 68 61 76 65 | 0a 58 20 20 62 65 65 6e |ust have|.X been|
|00002f30| 20 70 72 65 76 69 6f 75 | 73 6c 79 20 69 6e 69 74 | previou|sly init|
|00002f40| 69 61 6c 69 7a 65 64 20 | 76 69 61 20 61 70 6d 49 |ialized |via apmI|
|00002f50| 6e 69 74 28 29 2e 0a 58 | 0a 58 20 20 54 68 65 20 |nit()..X|.X The |
|00002f60| 27 72 65 73 75 6c 74 27 | 20 70 61 72 61 6d 65 74 |'result'| paramet|
|00002f70| 65 72 20 63 61 6e 6e 6f | 74 20 62 65 20 6f 6e 65 |er canno|t be one|
|00002f80| 20 6f 66 20 74 68 65 20 | 6f 74 68 65 72 20 41 50 | of the |other AP|
|00002f90| 4d 20 70 61 72 61 6d 65 | 74 65 72 73 2e 0a 58 0a |M parame|ters..X.|
|00002fa0| 58 20 20 54 68 65 20 72 | 65 74 75 72 6e 20 63 6f |X The r|eturn co|
|00002fb0| 64 65 20 61 6e 64 20 74 | 68 65 20 27 61 70 6d 5f |de and t|he 'apm_|
|00002fc0| 65 72 72 6e 6f 27 20 76 | 61 72 69 61 62 6c 65 20 |errno' v|ariable |
|00002fd0| 72 65 66 6c 65 63 74 20 | 74 68 65 20 73 74 61 74 |reflect |the stat|
|00002fe0| 75 73 20 6f 66 20 74 68 | 69 73 0a 58 20 20 66 75 |us of th|is.X fu|
|00002ff0| 6e 63 74 69 6f 6e 2e 0a | 58 0a 58 69 6e 74 0a 58 |nction..|X.Xint.X|
|00003000| 61 70 6d 44 69 76 69 64 | 65 28 71 75 6f 74 69 65 |apmDivid|e(quotie|
|00003010| 6e 74 2c 20 72 61 64 69 | 78 5f 70 6c 61 63 65 73 |nt, radi|x_places|
|00003020| 2c 20 72 65 6d 61 69 6e | 64 65 72 2c 20 61 70 6d |, remain|der, apm|
|00003030| 31 2c 20 61 70 6d 32 29 | 0a 58 41 50 4d 20 71 75 |1, apm2)|.XAPM qu|
|00003040| 6f 74 69 65 6e 74 3b 0a | 58 69 6e 74 20 72 61 64 |otient;.|Xint rad|
|00003050| 69 78 5f 70 6c 61 63 65 | 73 3b 0a 58 41 50 4d 20 |ix_place|s;.XAPM |
|00003060| 72 65 6d 61 69 6e 64 65 | 72 3b 0a 58 41 50 4d 20 |remainde|r;.XAPM |
|00003070| 61 70 6d 31 3b 0a 58 41 | 50 4d 20 61 70 6d 32 3b |apm1;.XA|PM apm2;|
|00003080| 0a 58 7b 7d 0a 58 20 20 | 54 68 69 73 20 72 6f 75 |.X{}.X |This rou|
|00003090| 74 69 6e 65 20 64 69 76 | 69 64 65 73 20 27 61 70 |tine div|ides 'ap|
|000030a0| 6d 31 27 20 62 79 20 27 | 61 70 6d 32 27 2c 20 70 |m1' by '|apm2', p|
|000030b0| 72 6f 64 75 63 69 6e 67 | 20 74 68 65 20 27 71 75 |roducing| the 'qu|
|000030c0| 6f 74 69 65 6e 74 27 20 | 61 6e 64 0a 58 20 20 27 |otient' |and.X '|
|000030d0| 72 65 6d 61 69 6e 64 65 | 72 27 20 76 61 72 69 61 |remainde|r' varia|
|000030e0| 62 6c 65 73 2e 20 20 55 | 6e 6c 69 6b 65 20 74 68 |bles. U|nlike th|
|000030f0| 65 20 6f 74 68 65 72 20 | 74 68 72 65 65 20 62 61 |e other |three ba|
|00003100| 73 69 63 20 6f 70 65 72 | 61 74 69 6f 6e 73 2c 0a |sic oper|ations,.|
|00003110| 58 20 20 64 69 76 69 73 | 69 6f 6e 20 63 61 6e 6e |X divis|ion cann|
|00003120| 6f 74 20 62 65 20 63 6f | 75 6e 74 65 64 20 6f 6e |ot be co|unted on|
|00003130| 20 74 6f 20 70 72 6f 64 | 75 63 65 20 6e 6f 6e 2d | to prod|uce non-|
|00003140| 72 65 70 65 61 74 69 6e | 67 20 64 65 63 69 6d 61 |repeatin|g decima|
|00003150| 6c 73 2c 20 73 6f 0a 58 | 20 20 74 68 65 20 27 72 |ls, so.X| the 'r|
|00003160| 61 64 69 78 5f 70 6c 61 | 63 65 73 27 20 76 61 72 |adix_pla|ces' var|
|00003170| 69 61 62 6c 65 20 65 78 | 69 73 74 73 20 74 6f 20 |iable ex|ists to |
|00003180| 74 65 6c 6c 20 74 68 69 | 73 20 72 6f 75 74 69 6e |tell thi|s routin|
|00003190| 65 20 68 6f 77 20 6d 61 | 6e 79 0a 58 20 20 64 69 |e how ma|ny.X di|
|000031a0| 67 69 74 73 20 74 6f 20 | 74 68 65 20 72 69 67 68 |gits to |the righ|
|000031b0| 74 20 6f 66 20 74 68 65 | 20 72 61 64 69 78 20 70 |t of the| radix p|
|000031c0| 6f 69 6e 74 20 61 72 65 | 20 74 6f 20 62 65 20 63 |oint are| to be c|
|000031d0| 61 6c 63 75 6c 61 74 65 | 64 20 62 65 66 6f 72 65 |alculate|d before|
|000031e0| 0a 58 20 20 73 74 6f 70 | 70 69 6e 67 2e 20 20 49 |.X stop|ping. I|
|000031f0| 66 20 74 68 65 20 27 72 | 65 6d 61 69 6e 64 65 72 |f the 'r|emainder|
|00003200| 27 20 76 61 72 69 61 62 | 6c 65 20 69 73 20 73 65 |' variab|le is se|
|00003210| 74 20 74 6f 20 28 41 50 | 4d 29 4e 55 4c 4c 2c 20 |t to (AP|M)NULL, |
|00003220| 6e 6f 0a 58 20 20 72 65 | 6d 61 69 6e 64 65 72 20 |no.X re|mainder |
|00003230| 69 73 20 63 61 6c 63 75 | 6c 61 74 65 64 20 2e 2e |is calcu|lated ..|
|00003240| 2e 20 74 68 69 73 20 73 | 61 76 65 73 20 71 75 69 |. this s|aves qui|
|00003250| 74 65 20 61 20 62 69 74 | 20 6f 66 20 63 6f 6d 70 |te a bit| of comp|
|00003260| 75 74 61 74 69 6f 6e 20 | 74 69 6d 65 0a 58 20 20 |utation |time.X |
|00003270| 61 6e 64 20 68 65 6e 63 | 65 20 69 73 20 72 65 63 |and henc|e is rec|
|00003280| 6f 6d 6d 65 6e 64 65 64 | 20 77 68 65 6e 65 76 65 |ommended| wheneve|
|00003290| 72 20 70 6f 73 73 69 62 | 6c 65 2e 0a 58 0a 58 20 |r possib|le..X.X |
|000032a0| 20 41 6c 6c 20 41 50 4d | 20 76 61 6c 75 65 73 20 | All APM| values |
|000032b0| 6d 75 73 74 20 68 61 76 | 65 20 62 65 65 6e 20 70 |must hav|e been p|
|000032c0| 72 65 76 69 6f 75 73 6c | 79 20 69 6e 69 74 69 61 |reviousl|y initia|
|000032d0| 6c 69 7a 65 64 20 76 69 | 61 20 61 70 6d 49 6e 69 |lized vi|a apmIni|
|000032e0| 74 28 29 20 28 65 78 63 | 65 70 74 2c 0a 58 20 20 |t() (exc|ept,.X |
|000032f0| 6f 66 20 63 6f 75 72 73 | 65 20 74 68 65 20 27 72 |of cours|e the 'r|
|00003300| 65 6d 61 69 6e 64 65 72 | 27 20 76 61 6c 75 65 20 |emainder|' value |
|00003310| 69 66 20 69 74 20 69 73 | 20 74 6f 20 62 65 20 73 |if it is| to be s|
|00003320| 65 74 20 74 6f 20 4e 55 | 4c 4c 29 2e 0a 58 0a 58 |et to NU|LL)..X.X|
|00003330| 20 20 44 69 76 69 73 69 | 6f 6e 20 62 79 20 7a 65 | Divisi|on by ze|
|00003340| 72 6f 20 63 72 65 61 74 | 65 73 20 61 20 7a 65 72 |ro creat|es a zer|
|00003350| 6f 20 72 65 73 75 6c 74 | 20 61 6e 64 20 61 20 77 |o result| and a w|
|00003360| 61 72 6e 69 6e 67 2e 0a | 58 0a 58 20 20 54 68 65 |arning..|X.X The|
|00003370| 20 27 71 75 6f 74 69 65 | 6e 74 27 20 61 6e 64 20 | 'quotie|nt' and |
|00003380| 27 72 65 6d 61 69 6e 64 | 65 72 27 20 76 61 72 69 |'remaind|er' vari|
|00003390| 61 62 6c 65 73 20 63 61 | 6e 27 74 20 62 65 20 6f |ables ca|n't be o|
|000033a0| 6e 65 20 6f 66 20 74 68 | 65 20 6f 74 68 65 72 20 |ne of th|e other |
|000033b0| 41 50 4d 0a 58 20 20 70 | 61 72 61 6d 65 74 65 72 |APM.X p|arameter|
|000033c0| 73 2e 0a 58 0a 58 20 20 | 54 68 65 20 72 65 74 75 |s..X.X |The retu|
|000033d0| 72 6e 20 63 6f 64 65 20 | 61 6e 64 20 74 68 65 20 |rn code |and the |
|000033e0| 27 61 70 6d 5f 65 72 72 | 6e 6f 27 20 76 61 72 69 |'apm_err|no' vari|
|000033f0| 61 62 6c 65 20 72 65 66 | 6c 65 63 74 20 74 68 65 |able ref|lect the|
|00003400| 20 73 74 61 74 75 73 20 | 6f 66 20 74 68 69 73 0a | status |of this.|
|00003410| 58 20 20 66 75 6e 63 74 | 69 6f 6e 2e 0a 58 0a 58 |X funct|ion..X.X|
|00003420| 69 6e 74 0a 58 61 70 6d | 43 6f 6d 70 61 72 65 28 |int.Xapm|Compare(|
|00003430| 61 70 6d 31 2c 20 61 70 | 6d 32 29 0a 58 41 50 4d |apm1, ap|m2).XAPM|
|00003440| 20 61 70 6d 31 3b 0a 58 | 41 50 4d 20 61 70 6d 32 | apm1;.X|APM apm2|
|00003450| 3b 0a 58 7b 7d 0a 58 20 | 20 54 68 69 73 20 72 6f |;.X{}.X | This ro|
|00003460| 75 74 69 6e 65 20 63 6f | 6d 70 61 72 65 73 20 27 |utine co|mpares '|
|00003470| 61 70 6d 31 27 20 61 6e | 64 20 27 61 70 6d 32 27 |apm1' an|d 'apm2'|
|00003480| 2c 20 72 65 74 75 72 6e | 69 6e 67 20 2d 31 20 69 |, return|ing -1 i|
|00003490| 66 20 27 61 70 6d 31 27 | 20 69 73 20 6c 65 73 73 |f 'apm1'| is less|
|000034a0| 20 74 68 61 6e 0a 58 20 | 20 27 61 70 6d 32 27 2c | than.X | 'apm2',|
|000034b0| 20 31 20 69 66 20 27 61 | 70 6d 31 27 20 69 73 20 | 1 if 'a|pm1' is |
|000034c0| 67 72 65 61 74 65 72 20 | 74 68 61 6e 20 27 61 70 |greater |than 'ap|
|000034d0| 6d 32 27 2c 20 61 6e 64 | 20 30 20 69 66 20 74 68 |m2', and| 0 if th|
|000034e0| 65 79 20 61 72 65 20 65 | 71 75 61 6c 2e 0a 58 0a |ey are e|qual..X.|
|000034f0| 58 20 20 49 74 20 69 73 | 20 6e 6f 74 20 61 6e 20 |X It is| not an |
|00003500| 65 72 72 6f 72 20 69 66 | 20 27 61 70 6d 31 27 20 |error if| 'apm1' |
|00003510| 61 6e 64 20 27 61 70 6d | 32 27 20 61 72 65 20 69 |and 'apm|2' are i|
|00003520| 64 65 6e 74 69 63 61 6c | 2c 20 61 6e 64 20 69 6e |dentical|, and in|
|00003530| 20 74 68 69 73 20 63 61 | 73 65 20 74 68 65 0a 58 | this ca|se the.X|
|00003540| 20 20 72 65 74 75 72 6e | 20 76 61 6c 75 65 20 69 | return| value i|
|00003550| 73 20 30 2e 0a 58 0a 58 | 20 20 54 68 65 20 27 61 |s 0..X.X| The 'a|
|00003560| 70 6d 5f 65 72 72 6e 6f | 27 20 76 61 72 69 61 62 |pm_errno|' variab|
|00003570| 6c 65 20 63 6f 6e 74 61 | 69 6e 73 20 74 68 65 20 |le conta|ins the |
|00003580| 65 72 72 6f 72 20 63 6f | 64 65 2e 20 20 59 6f 75 |error co|de. You|
|00003590| 20 6d 75 73 74 20 63 68 | 65 63 6b 20 74 68 69 73 | must ch|eck this|
|000035a0| 20 76 61 6c 75 65 3a 0a | 58 20 20 69 66 20 69 74 | value:.|X if it|
|000035b0| 20 69 73 20 73 65 74 20 | 74 6f 20 61 6e 20 65 72 | is set |to an er|
|000035c0| 72 6f 72 20 69 6e 64 69 | 63 61 74 69 6f 6e 2c 20 |ror indi|cation, |
|000035d0| 74 68 65 20 63 6f 6d 70 | 61 72 69 73 6f 6e 20 66 |the comp|arison f|
|000035e0| 61 69 6c 65 64 20 61 6e | 64 20 74 68 65 20 72 65 |ailed an|d the re|
|000035f0| 74 75 72 6e 0a 58 20 20 | 76 61 6c 75 65 20 69 73 |turn.X |value is|
|00003600| 20 74 68 65 72 65 66 6f | 72 65 20 6d 65 61 6e 69 | therefo|re meani|
|00003610| 6e 67 6c 65 73 73 2e 0a | 58 0a 58 69 6e 74 0a 58 |ngless..|X.Xint.X|
|00003620| 61 70 6d 43 6f 6d 70 61 | 72 65 4c 6f 6e 67 28 61 |apmCompa|reLong(a|
|00003630| 70 6d 2c 20 6c 6f 6e 67 | 76 61 6c 2c 20 73 63 61 |pm, long|val, sca|
|00003640| 6c 65 5f 66 61 63 74 6f | 72 2c 20 62 61 73 65 29 |le_facto|r, base)|
|00003650| 0a 58 41 50 4d 20 61 70 | 6d 3b 0a 58 6c 6f 6e 67 |.XAPM ap|m;.Xlong|
|00003660| 20 6c 6f 6e 67 76 61 6c | 3b 0a 58 69 6e 74 20 73 | longval|;.Xint s|
|00003670| 63 61 6c 65 5f 66 61 63 | 74 6f 72 3b 0a 58 73 68 |cale_fac|tor;.Xsh|
|00003680| 6f 72 74 20 62 61 73 65 | 3b 0a 58 7b 7d 0a 58 20 |ort base|;.X{}.X |
|00003690| 20 54 68 69 73 20 72 6f | 75 74 69 6e 65 20 77 6f | This ro|utine wo|
|000036a0| 72 6b 73 20 6a 75 73 74 | 20 6c 69 6b 65 20 61 70 |rks just| like ap|
|000036b0| 6d 43 6f 6d 70 61 72 65 | 28 29 2c 20 62 75 74 20 |mCompare|(), but |
|000036c0| 69 74 20 63 6f 6d 70 61 | 72 65 73 20 74 68 65 20 |it compa|res the |
|000036d0| 27 61 70 6d 27 20 76 61 | 6c 75 65 20 74 6f 0a 58 |'apm' va|lue to.X|
|000036e0| 20 20 27 6c 6f 6e 67 76 | 61 6c 27 2c 20 73 63 61 | 'longv|al', sca|
|000036f0| 6c 65 64 20 62 79 20 27 | 73 63 61 6c 65 5f 66 61 |led by '|scale_fa|
|00003700| 63 74 6f 72 27 20 69 6e | 20 27 62 61 73 65 27 2e |ctor' in| 'base'.|
|00003710| 20 20 54 68 65 20 27 61 | 70 6d 5f 65 72 72 6e 6f | The 'a|pm_errno|
|00003720| 27 20 76 61 72 69 61 62 | 6c 65 0a 58 20 20 63 6f |' variab|le.X co|
|00003730| 6e 74 61 69 6e 73 20 74 | 68 65 20 65 72 72 6f 72 |ntains t|he error|
|00003740| 20 63 6f 64 65 2e 0a 58 | 0a 58 69 6e 74 0a 58 61 | code..X|.Xint.Xa|
|00003750| 70 6d 53 69 67 6e 28 61 | 70 6d 29 0a 58 41 50 4d |pmSign(a|pm).XAPM|
|00003760| 20 61 70 6d 3b 0a 58 7b | 7d 0a 58 20 20 54 68 69 | apm;.X{|}.X Thi|
|00003770| 73 20 72 6f 75 74 69 6e | 65 20 72 65 74 75 72 6e |s routin|e return|
|00003780| 73 20 74 68 65 20 73 69 | 67 6e 20 6f 66 20 74 68 |s the si|gn of th|
|00003790| 65 20 27 61 70 6d 27 20 | 76 61 6c 75 65 3a 20 2d |e 'apm' |value: -|
|000037a0| 31 20 66 6f 72 20 6e 65 | 67 61 74 69 76 65 2c 20 |1 for ne|gative, |
|000037b0| 31 20 66 6f 72 0a 58 20 | 20 70 6f 73 69 74 69 76 |1 for.X | positiv|
|000037c0| 65 2e 20 20 54 68 65 20 | 27 61 70 6d 5f 65 72 72 |e. The |'apm_err|
|000037d0| 6e 6f 27 20 76 61 72 69 | 61 62 6c 65 20 63 6f 6e |no' vari|able con|
|000037e0| 74 61 69 6e 73 20 74 68 | 65 20 65 72 72 6f 72 20 |tains th|e error |
|000037f0| 63 6f 64 65 2e 20 20 59 | 6f 75 20 6d 75 73 74 20 |code. Y|ou must |
|00003800| 63 68 65 63 6b 0a 58 20 | 20 27 61 70 6d 5f 65 72 |check.X | 'apm_er|
|00003810| 72 6e 6f 27 3a 20 69 66 | 20 69 74 27 73 20 6e 6f |rno': if| it's no|
|00003820| 6e 2d 7a 65 72 6f 2c 20 | 74 68 65 20 66 75 6e 63 |n-zero, |the func|
|00003830| 74 69 6f 6e 20 72 65 74 | 75 72 6e 20 76 61 6c 75 |tion ret|urn valu|
|00003840| 65 20 69 73 20 6d 65 61 | 6e 69 6e 67 6c 65 73 73 |e is mea|ningless|
|00003850| 2e 0a 58 0a 58 69 6e 74 | 0a 58 61 70 6d 41 62 73 |..X.Xint|.XapmAbs|
|00003860| 6f 6c 75 74 65 56 61 6c | 75 65 28 72 65 73 75 6c |oluteVal|ue(resul|
|00003870| 74 2c 20 61 70 6d 29 0a | 58 41 50 4d 20 72 65 73 |t, apm).|XAPM res|
|00003880| 75 6c 74 3b 0a 58 41 50 | 4d 20 61 70 6d 3b 0a 58 |ult;.XAP|M apm;.X|
|00003890| 7b 7d 0a 58 20 20 54 68 | 69 73 20 72 6f 75 74 69 |{}.X Th|is routi|
|000038a0| 6e 65 20 70 75 74 73 20 | 74 68 65 20 61 62 73 6f |ne puts |the abso|
|000038b0| 6c 75 74 65 20 76 61 6c | 75 65 20 6f 66 20 27 61 |lute val|ue of 'a|
|000038c0| 70 6d 27 20 69 6e 74 6f | 20 27 72 65 73 75 6c 74 |pm' into| 'result|
|000038d0| 27 2c 20 77 68 6f 73 65 | 20 70 72 65 76 69 6f 75 |', whose| previou|
|000038e0| 73 0a 58 20 20 76 61 6c | 75 65 20 69 73 20 64 65 |s.X val|ue is de|
|000038f0| 73 74 72 6f 79 65 64 2e | 20 20 4e 6f 74 65 20 74 |stroyed.| Note t|
|00003900| 68 61 74 20 74 68 65 20 | 74 77 6f 20 70 61 72 61 |hat the |two para|
|00003910| 6d 65 74 65 72 73 20 6d | 75 73 74 20 68 61 76 65 |meters m|ust have|
|00003920| 20 62 65 65 6e 20 70 72 | 65 76 69 6f 75 73 6c 79 | been pr|eviously|
|00003930| 0a 58 20 20 69 6e 69 74 | 69 61 6c 69 7a 65 64 20 |.X init|ialized |
|00003940| 76 69 61 20 61 70 6d 49 | 6e 69 74 28 29 2e 0a 58 |via apmI|nit()..X|
|00003950| 0a 58 20 20 54 68 65 20 | 27 72 65 73 75 6c 74 27 |.X The |'result'|
|00003960| 20 70 61 72 61 6d 65 74 | 65 72 20 63 61 6e 6e 6f | paramet|er canno|
|00003970| 74 20 62 65 20 74 68 65 | 20 6f 74 68 65 72 20 41 |t be the| other A|
|00003980| 50 4d 20 70 61 72 61 6d | 65 74 65 72 2e 0a 58 0a |PM param|eter..X.|
|00003990| 58 20 20 54 68 65 20 72 | 65 74 75 72 6e 20 63 6f |X The r|eturn co|
|000039a0| 64 65 20 61 6e 64 20 74 | 68 65 20 27 61 70 6d 5f |de and t|he 'apm_|
|000039b0| 65 72 72 6e 6f 27 20 76 | 61 72 69 61 62 6c 65 20 |errno' v|ariable |
|000039c0| 72 65 66 6c 65 63 74 20 | 74 68 65 20 73 74 61 74 |reflect |the stat|
|000039d0| 75 73 20 6f 66 20 74 68 | 69 73 0a 58 20 20 66 75 |us of th|is.X fu|
|000039e0| 6e 63 74 69 6f 6e 2e 0a | 58 0a 58 69 6e 74 0a 58 |nction..|X.Xint.X|
|000039f0| 61 70 6d 4e 65 67 61 74 | 65 28 72 65 73 75 6c 74 |apmNegat|e(result|
|00003a00| 2c 20 61 70 6d 29 0a 58 | 41 50 4d 20 72 65 73 75 |, apm).X|APM resu|
|00003a10| 6c 74 3b 0a 58 41 50 4d | 20 6e 75 6d 3b 0a 58 7b |lt;.XAPM| num;.X{|
|00003a20| 7d 0a 58 20 20 54 68 69 | 73 20 72 6f 75 74 69 6e |}.X Thi|s routin|
|00003a30| 65 20 70 75 74 73 20 74 | 68 65 20 61 64 64 69 74 |e puts t|he addit|
|00003a40| 69 76 65 20 69 6e 76 65 | 72 73 65 20 6f 66 20 27 |ive inve|rse of '|
|00003a50| 61 70 6d 27 20 69 6e 74 | 6f 20 27 72 65 73 75 6c |apm' int|o 'resul|
|00003a60| 74 27 2c 20 77 68 6f 73 | 65 20 70 72 65 76 69 6f |t', whos|e previo|
|00003a70| 75 73 0a 58 20 20 76 61 | 6c 75 65 20 69 73 20 64 |us.X va|lue is d|
|00003a80| 65 73 74 72 6f 79 65 64 | 2e 20 20 4e 6f 74 65 20 |estroyed|. Note |
|00003a90| 74 68 61 74 20 74 68 65 | 20 74 77 6f 20 70 61 72 |that the| two par|
|00003aa0| 61 6d 65 74 65 72 73 20 | 6d 75 73 74 20 68 61 76 |ameters |must hav|
|00003ab0| 65 20 62 65 65 6e 20 70 | 72 65 76 69 6f 75 73 6c |e been p|reviousl|
|00003ac0| 79 0a 58 20 20 69 6e 69 | 74 69 61 6c 69 7a 65 64 |y.X ini|tialized|
|00003ad0| 20 76 69 61 20 61 70 6d | 49 6e 69 74 28 29 2e 0a | via apm|Init()..|
|00003ae0| 58 0a 58 20 20 54 68 65 | 20 27 72 65 73 75 6c 74 |X.X The| 'result|
|00003af0| 27 20 70 61 72 61 6d 65 | 74 65 72 20 63 61 6e 6e |' parame|ter cann|
|00003b00| 6f 74 20 62 65 20 74 68 | 65 20 6f 74 68 65 72 20 |ot be th|e other |
|00003b10| 41 50 4d 20 70 61 72 61 | 6d 65 74 65 72 2e 0a 58 |APM para|meter..X|
|00003b20| 0a 58 20 20 54 68 65 20 | 72 65 74 75 72 6e 20 63 |.X The |return c|
|00003b30| 6f 64 65 20 61 6e 64 20 | 74 68 65 20 27 61 70 6d |ode and |the 'apm|
|00003b40| 5f 65 72 72 6e 6f 27 20 | 76 61 72 69 61 62 6c 65 |_errno' |variable|
|00003b50| 20 72 65 66 6c 65 63 74 | 20 74 68 65 20 73 74 61 | reflect| the sta|
|00003b60| 74 75 73 20 6f 66 20 74 | 68 69 73 0a 58 20 20 66 |tus of t|his.X f|
|00003b70| 75 6e 63 74 69 6f 6e 2e | 0a 58 0a 58 69 6e 74 0a |unction.|.X.Xint.|
|00003b80| 58 61 70 6d 52 65 63 69 | 70 72 6f 63 61 6c 28 72 |XapmReci|procal(r|
|00003b90| 65 73 75 6c 74 2c 20 72 | 61 64 69 78 5f 70 6c 61 |esult, r|adix_pla|
|00003ba0| 63 65 73 2c 20 61 70 6d | 29 0a 58 41 50 4d 20 72 |ces, apm|).XAPM r|
|00003bb0| 65 73 75 6c 74 3b 0a 58 | 69 6e 74 20 72 61 64 69 |esult;.X|int radi|
|00003bc0| 78 5f 70 6c 61 63 65 73 | 3b 0a 58 41 50 4d 20 6e |x_places|;.XAPM n|
|00003bd0| 75 6d 3b 0a 58 7b 7d 0a | 58 20 20 54 68 69 73 20 |um;.X{}.|X This |
|00003be0| 72 6f 75 74 69 6e 65 20 | 70 75 74 73 20 74 68 65 |routine |puts the|
|00003bf0| 20 6d 75 6c 74 69 70 6c | 69 63 61 74 69 76 65 20 | multipl|icative |
|00003c00| 69 6e 76 65 72 73 65 20 | 6f 66 20 27 61 70 6d 27 |inverse |of 'apm'|
|00003c10| 20 69 6e 74 6f 20 27 72 | 65 73 75 6c 74 27 2c 20 | into 'r|esult', |
|00003c20| 77 68 6f 73 65 0a 58 20 | 20 70 72 65 76 69 6f 75 |whose.X | previou|
|00003c30| 73 20 76 61 6c 75 65 20 | 69 73 20 64 65 73 74 72 |s value |is destr|
|00003c40| 6f 79 65 64 2e 20 20 4e | 6f 74 65 20 74 68 61 74 |oyed. N|ote that|
|00003c50| 20 74 68 65 20 74 77 6f | 20 41 50 4d 20 70 61 72 | the two| APM par|
|00003c60| 61 6d 65 74 65 72 73 20 | 6d 75 73 74 20 68 61 76 |ameters |must hav|
|00003c70| 65 20 62 65 65 6e 0a 58 | 20 20 70 72 65 76 69 6f |e been.X| previo|
|00003c80| 75 73 6c 79 20 69 6e 69 | 74 69 61 6c 69 7a 65 64 |usly ini|tialized|
|00003c90| 20 76 69 61 20 61 70 6d | 49 6e 69 74 28 29 2e 20 | via apm|Init(). |
|00003ca0| 20 53 69 6e 63 65 20 74 | 61 6b 69 6e 67 20 74 68 | Since t|aking th|
|00003cb0| 65 20 72 65 63 69 70 72 | 6f 63 61 6c 20 69 6e 76 |e recipr|ocal inv|
|00003cc0| 6f 6c 76 65 73 0a 58 20 | 20 64 6f 69 6e 67 20 61 |olves.X | doing a|
|00003cd0| 20 64 69 76 69 73 69 6f | 6e 2c 20 74 68 65 20 27 | divisio|n, the '|
|00003ce0| 72 61 64 69 78 5f 70 6c | 61 63 65 73 27 20 70 61 |radix_pl|aces' pa|
|00003cf0| 72 61 6d 65 74 65 72 20 | 69 73 20 6e 65 65 64 65 |rameter |is neede|
|00003d00| 64 20 68 65 72 65 20 66 | 6f 72 20 74 68 65 20 73 |d here f|or the s|
|00003d10| 61 6d 65 0a 58 20 20 72 | 65 61 73 6f 6e 20 69 74 |ame.X r|eason it|
|00003d20| 27 73 20 6e 65 65 64 65 | 64 20 69 6e 20 74 68 65 |'s neede|d in the|
|00003d30| 20 61 70 6d 44 69 76 69 | 64 65 28 29 20 72 6f 75 | apmDivi|de() rou|
|00003d40| 74 69 6e 65 2e 0a 58 0a | 58 20 20 54 61 6b 69 6e |tine..X.|X Takin|
|00003d50| 67 20 74 68 65 20 72 65 | 63 69 70 72 6f 63 61 6c |g the re|ciprocal|
|00003d60| 20 6f 66 20 7a 65 72 6f | 20 79 69 65 6c 64 73 20 | of zero| yields |
|00003d70| 7a 65 72 6f 20 77 69 74 | 68 20 61 20 77 61 72 6e |zero wit|h a warn|
|00003d80| 69 6e 67 20 73 74 61 74 | 75 73 2e 0a 58 0a 58 20 |ing stat|us..X.X |
|00003d90| 20 54 68 65 20 27 72 65 | 73 75 6c 74 27 20 70 61 | The 're|sult' pa|
|00003da0| 72 61 6d 65 74 65 72 20 | 63 61 6e 6e 6f 74 20 62 |rameter |cannot b|
|00003db0| 65 20 74 68 65 20 6f 74 | 68 65 72 20 41 50 4d 20 |e the ot|her APM |
|00003dc0| 70 61 72 61 6d 65 74 65 | 72 2e 0a 58 0a 58 20 20 |paramete|r..X.X |
|00003dd0| 54 68 65 20 72 65 74 75 | 72 6e 20 63 6f 64 65 20 |The retu|rn code |
|00003de0| 61 6e 64 20 74 68 65 20 | 27 61 70 6d 5f 65 72 72 |and the |'apm_err|
|00003df0| 6e 6f 27 20 76 61 72 69 | 61 62 6c 65 20 72 65 66 |no' vari|able ref|
|00003e00| 6c 65 63 74 20 74 68 65 | 20 73 74 61 74 75 73 20 |lect the| status |
|00003e10| 6f 66 20 74 68 69 73 0a | 58 20 20 66 75 6e 63 74 |of this.|X funct|
|00003e20| 69 6f 6e 2e 0a 58 0a 58 | 69 6e 74 0a 58 61 70 6d |ion..X.X|int.Xapm|
|00003e30| 53 63 61 6c 65 28 72 65 | 73 75 6c 74 2c 20 61 70 |Scale(re|sult, ap|
|00003e40| 6d 2c 20 73 63 61 6c 65 | 5f 66 61 63 74 6f 72 29 |m, scale|_factor)|
|00003e50| 0a 58 41 50 4d 20 72 65 | 73 75 6c 74 3b 0a 58 41 |.XAPM re|sult;.XA|
|00003e60| 50 4d 20 61 70 6d 3b 0a | 58 69 6e 74 20 73 63 61 |PM apm;.|Xint sca|
|00003e70| 6c 65 5f 66 61 63 74 6f | 72 3b 0a 58 7b 7d 0a 58 |le_facto|r;.X{}.X|
|00003e80| 20 20 54 68 69 73 20 72 | 6f 75 74 69 6e 65 20 61 | This r|outine a|
|00003e90| 73 73 69 67 6e 73 20 74 | 6f 20 27 72 65 73 75 6c |ssigns t|o 'resul|
|00003ea0| 74 27 20 74 68 65 20 76 | 61 6c 75 65 20 6f 66 20 |t' the v|alue of |
|00003eb0| 27 61 70 6d 27 20 77 69 | 74 68 20 69 74 73 20 72 |'apm' wi|th its r|
|00003ec0| 61 64 69 78 20 70 6f 69 | 6e 74 0a 58 20 20 73 68 |adix poi|nt.X sh|
|00003ed0| 69 66 74 65 64 20 62 79 | 20 27 73 63 61 6c 65 5f |ifted by| 'scale_|
|00003ee0| 66 61 63 74 6f 72 27 20 | 28 70 6f 73 69 74 69 76 |factor' |(positiv|
|00003ef0| 65 20 27 73 63 61 6c 65 | 5f 66 61 63 74 6f 72 27 |e 'scale|_factor'|
|00003f00| 20 6d 65 61 6e 73 20 73 | 68 69 66 74 20 6c 65 66 | means s|hift lef|
|00003f10| 74 29 2e 20 20 54 68 65 | 0a 58 20 20 27 73 63 61 |t). The|.X 'sca|
|00003f20| 6c 65 5f 66 61 63 74 6f | 72 27 20 72 65 70 72 65 |le_facto|r' repre|
|00003f30| 73 65 6e 74 73 20 68 6f | 77 20 6d 61 6e 79 20 70 |sents ho|w many p|
|00003f40| 6c 61 63 65 73 20 74 68 | 65 20 72 61 64 69 78 20 |laces th|e radix |
|00003f50| 69 73 20 73 68 69 66 74 | 65 64 20 69 6e 20 74 68 |is shift|ed in th|
|00003f60| 65 20 62 61 73 65 20 6f | 66 0a 58 20 20 27 61 70 |e base o|f.X 'ap|
|00003f70| 6d 27 20 75 6e 6c 65 73 | 73 20 27 61 70 6d 27 20 |m' unles|s 'apm' |
|00003f80| 69 73 20 69 6e 20 62 61 | 73 65 20 31 30 30 30 30 |is in ba|se 10000|
|00003f90| 20 2e 2e 2e 20 20 69 6e | 20 74 68 69 73 20 73 70 | ... in| this sp|
|00003fa0| 65 63 69 61 6c 20 63 61 | 73 65 2c 20 27 73 63 61 |ecial ca|se, 'sca|
|00003fb0| 6c 65 5f 66 61 63 74 6f | 72 27 0a 58 20 20 69 73 |le_facto|r'.X is|
|00003fc0| 20 74 72 65 61 74 65 64 | 20 61 73 20 69 66 20 74 | treated| as if t|
|00003fd0| 68 65 20 62 61 73 65 20 | 77 65 72 65 20 31 30 2e |he base |were 10.|
|00003fe0| 0a 58 0a 58 20 20 54 68 | 69 73 20 69 73 20 61 20 |.X.X Th|is is a |
|00003ff0| 76 65 72 79 20 71 75 69 | 63 6b 20 61 6e 64 20 61 |very qui|ck and a|
|00004000| 63 63 75 72 61 74 65 20 | 77 61 79 20 74 6f 20 6d |ccurate |way to m|
|00004010| 75 6c 74 69 70 6c 79 20 | 6f 72 20 64 69 76 69 64 |ultiply |or divid|
|00004020| 65 20 62 79 20 61 20 70 | 6f 77 65 72 20 6f 66 20 |e by a p|ower of |
|00004030| 31 30 0a 58 20 20 28 6f | 72 20 74 68 65 20 6e 75 |10.X (o|r the nu|
|00004040| 6d 62 65 72 27 73 20 62 | 61 73 65 29 2e 0a 58 0a |mber's b|ase)..X.|
|00004050| 58 20 20 54 68 65 20 27 | 72 65 73 75 6c 74 27 20 |X The '|result' |
|00004060| 70 61 72 61 6d 65 74 65 | 72 20 63 61 6e 6e 6f 74 |paramete|r cannot|
|00004070| 20 62 65 20 74 68 65 20 | 6f 74 68 65 72 20 41 50 | be the |other AP|
|00004080| 4d 20 70 61 72 61 6d 65 | 74 65 72 2e 0a 58 0a 58 |M parame|ter..X.X|
|00004090| 20 20 54 68 65 20 72 65 | 74 75 72 6e 20 63 6f 64 | The re|turn cod|
|000040a0| 65 20 61 6e 64 20 74 68 | 65 20 27 61 70 6d 5f 65 |e and th|e 'apm_e|
|000040b0| 72 72 6e 6f 27 20 76 61 | 72 69 61 62 6c 65 20 72 |rrno' va|riable r|
|000040c0| 65 66 6c 65 63 74 20 74 | 68 65 20 73 74 61 74 75 |eflect t|he statu|
|000040d0| 73 20 6f 66 20 74 68 69 | 73 0a 58 20 20 66 75 6e |s of thi|s.X fun|
|000040e0| 63 74 69 6f 6e 2e 0a 58 | 0a 58 69 6e 74 0a 58 61 |ction..X|.Xint.Xa|
|000040f0| 70 6d 56 61 6c 69 64 61 | 74 65 28 61 70 6d 29 0a |pmValida|te(apm).|
|00004100| 58 41 50 4d 20 61 70 6d | 3b 0a 58 7b 7d 0a 58 20 |XAPM apm|;.X{}.X |
|00004110| 20 54 68 69 73 20 72 6f | 75 74 69 6e 65 20 73 65 | This ro|utine se|
|00004120| 74 73 20 27 61 70 6d 5f | 65 72 72 6e 6f 27 20 61 |ts 'apm_|errno' a|
|00004130| 6e 64 20 69 74 73 20 72 | 65 74 75 72 6e 20 73 74 |nd its r|eturn st|
|00004140| 61 74 75 73 20 74 6f 20 | 73 6f 6d 65 20 6e 6f 6e |atus to |some non|
|00004150| 2d 7a 65 72 6f 20 76 61 | 6c 75 65 20 69 66 0a 58 |-zero va|lue if.X|
|00004160| 20 20 27 61 70 6d 27 20 | 69 73 20 6e 6f 74 20 61 | 'apm' |is not a|
|00004170| 20 76 61 6c 69 64 20 41 | 50 4d 20 76 61 6c 75 65 | valid A|PM value|
|00004180| 2e 0a 58 0a 58 69 6e 74 | 0a 58 61 70 6d 41 73 73 |..X.Xint|.XapmAss|
|00004190| 69 67 6e 28 72 65 73 75 | 6c 74 2c 20 61 70 6d 29 |ign(resu|lt, apm)|
|000041a0| 0a 58 41 50 4d 20 72 65 | 73 75 6c 74 3b 0a 58 41 |.XAPM re|sult;.XA|
|000041b0| 50 4d 20 6e 75 6d 3b 0a | 58 7b 7d 0a 58 20 20 54 |PM num;.|X{}.X T|
|000041c0| 68 69 73 20 72 6f 75 74 | 69 6e 65 20 61 73 73 69 |his rout|ine assi|
|000041d0| 67 6e 73 20 74 68 65 20 | 76 61 6c 75 65 20 6f 66 |gns the |value of|
|000041e0| 20 27 61 70 6d 27 20 74 | 6f 20 27 72 65 73 75 6c | 'apm' t|o 'resul|
|000041f0| 74 27 2c 20 77 68 6f 73 | 65 20 70 72 65 76 69 6f |t', whos|e previo|
|00004200| 75 73 20 76 61 6c 75 65 | 20 69 73 0a 58 20 20 64 |us value| is.X d|
|00004210| 65 73 74 72 6f 79 65 64 | 2e 20 20 4e 6f 74 65 20 |estroyed|. Note |
|00004220| 74 68 61 74 20 74 68 65 | 20 74 77 6f 20 70 61 72 |that the| two par|
|00004230| 61 6d 65 74 65 72 73 20 | 6d 75 73 74 20 68 61 76 |ameters |must hav|
|00004240| 65 20 62 65 65 6e 20 70 | 72 65 76 69 6f 75 73 6c |e been p|reviousl|
|00004250| 79 0a 58 20 20 69 6e 69 | 74 69 61 6c 69 7a 65 64 |y.X ini|tialized|
|00004260| 20 76 69 61 20 61 70 6d | 49 6e 69 74 28 29 2e 0a | via apm|Init()..|
|00004270| 58 0a 58 20 20 49 74 20 | 69 73 20 6e 6f 74 20 63 |X.X It |is not c|
|00004280| 6f 6e 73 69 64 65 72 65 | 64 20 61 6e 20 65 72 72 |onsidere|d an err|
|00004290| 6f 72 20 69 66 20 27 72 | 65 73 75 6c 74 27 20 61 |or if 'r|esult' a|
|000042a0| 6e 64 20 27 61 70 6d 27 | 20 61 72 65 20 69 64 65 |nd 'apm'| are ide|
|000042b0| 6e 74 69 63 61 6c 3b 20 | 74 68 69 73 20 63 61 73 |ntical; |this cas|
|000042c0| 65 0a 58 20 20 69 73 20 | 61 20 76 69 72 74 75 61 |e.X is |a virtua|
|000042d0| 6c 20 6e 6f 2d 6f 70 2e | 0a 58 0a 58 20 20 54 68 |l no-op.|.X.X Th|
|000042e0| 65 20 72 65 74 75 72 6e | 20 63 6f 64 65 20 61 6e |e return| code an|
|000042f0| 64 20 74 68 65 20 27 61 | 70 6d 5f 65 72 72 6e 6f |d the 'a|pm_errno|
|00004300| 27 20 76 61 72 69 61 62 | 6c 65 20 72 65 66 6c 65 |' variab|le refle|
|00004310| 63 74 20 74 68 65 20 73 | 74 61 74 75 73 20 6f 66 |ct the s|tatus of|
|00004320| 20 74 68 69 73 0a 58 20 | 20 66 75 6e 63 74 69 6f | this.X | functio|
|00004330| 6e 2e 0a 58 0a 58 69 6e | 74 0a 58 61 70 6d 41 73 |n..X.Xin|t.XapmAs|
|00004340| 73 69 67 6e 4c 6f 6e 67 | 28 72 65 73 75 6c 74 2c |signLong|(result,|
|00004350| 20 6c 6f 6e 67 5f 76 61 | 6c 75 65 2c 20 73 63 61 | long_va|lue, sca|
|00004360| 6c 65 5f 66 61 63 74 6f | 72 2c 20 62 61 73 65 29 |le_facto|r, base)|
|00004370| 0a 58 41 50 4d 20 72 65 | 73 75 6c 74 3b 0a 58 6c |.XAPM re|sult;.Xl|
|00004380| 6f 6e 67 20 6c 6f 6e 67 | 5f 76 61 6c 75 65 3b 0a |ong long|_value;.|
|00004390| 58 69 6e 74 20 73 63 61 | 6c 65 5f 66 61 63 74 6f |Xint sca|le_facto|
|000043a0| 72 3b 0a 58 73 68 6f 72 | 74 20 62 61 73 65 3b 0a |r;.Xshor|t base;.|
|000043b0| 58 7b 7d 0a 58 20 20 54 | 68 69 73 20 72 6f 75 74 |X{}.X T|his rout|
|000043c0| 69 6e 65 20 61 73 73 69 | 67 6e 73 20 61 20 6c 6f |ine assi|gns a lo|
|000043d0| 6e 67 20 69 6e 74 20 74 | 6f 20 27 72 65 73 75 6c |ng int t|o 'resul|
|000043e0| 74 27 2e 20 20 49 74 73 | 20 73 65 63 6f 6e 64 20 |t'. Its| second |
|000043f0| 74 68 72 6f 75 67 68 20 | 66 6f 75 72 74 68 0a 58 |through |fourth.X|
|00004400| 20 20 70 61 72 61 6d 65 | 74 65 72 73 20 63 6f 72 | parame|ters cor|
|00004410| 72 65 73 70 6f 6e 64 20 | 65 78 61 63 74 6c 79 20 |respond |exactly |
|00004420| 74 6f 20 74 68 65 20 70 | 61 72 61 6d 65 74 65 72 |to the p|arameter|
|00004430| 73 20 6f 66 20 61 70 6d | 49 6e 69 74 28 29 2e 20 |s of apm|Init(). |
|00004440| 20 54 68 65 20 6f 6e 6c | 79 0a 58 20 20 64 69 66 | The onl|y.X dif|
|00004450| 66 65 72 65 6e 63 65 20 | 62 65 74 77 65 65 6e 20 |ference |between |
|00004460| 74 68 65 20 74 77 6f 20 | 72 6f 75 74 69 6e 65 73 |the two |routines|
|00004470| 20 69 73 20 74 68 61 74 | 20 74 68 69 73 20 6f 6e | is that| this on|
|00004480| 65 20 72 65 71 75 69 72 | 65 73 20 74 68 61 74 20 |e requir|es that |
|00004490| 69 74 73 20 72 65 73 75 | 6c 74 0a 58 20 20 62 65 |its resu|lt.X be|
|000044a0| 20 70 72 65 76 69 6f 75 | 73 6c 79 20 69 6e 69 74 | previou|sly init|
|000044b0| 69 61 6c 69 7a 65 64 2e | 20 20 54 68 65 20 27 6c |ialized.| The 'l|
|000044c0| 6f 6e 67 5f 76 61 6c 75 | 65 27 20 70 61 72 61 6d |ong_valu|e' param|
|000044d0| 65 74 65 72 20 69 73 20 | 61 20 6c 6f 6e 67 20 74 |eter is |a long t|
|000044e0| 68 61 74 0a 58 20 20 72 | 65 70 72 65 73 65 6e 74 |hat.X r|epresent|
|000044f0| 73 20 74 68 65 20 76 61 | 6c 75 65 20 74 6f 20 61 |s the va|lue to a|
|00004500| 73 73 69 67 6e 20 74 6f | 20 27 72 65 73 75 6c 74 |ssign to| 'result|
|00004510| 27 2c 20 74 68 65 20 27 | 73 63 61 6c 65 5f 66 61 |', the '|scale_fa|
|00004520| 63 74 6f 72 27 20 76 61 | 72 69 61 62 6c 65 0a 58 |ctor' va|riable.X|
|00004530| 20 20 69 6e 64 69 63 61 | 74 65 73 20 68 6f 77 20 | indica|tes how |
|00004540| 74 68 69 73 20 76 61 6c | 75 65 20 73 68 6f 75 6c |this val|ue shoul|
|00004550| 64 20 62 65 20 73 63 61 | 6c 65 64 2c 20 61 6e 64 |d be sca|led, and|
|00004560| 20 27 62 61 73 65 27 20 | 69 73 20 74 68 65 20 62 | 'base' |is the b|
|00004570| 61 73 65 20 6f 66 20 74 | 68 65 0a 58 20 20 76 61 |ase of t|he.X va|
|00004580| 6c 75 65 2e 0a 58 0a 58 | 20 20 42 61 73 65 73 20 |lue..X.X| Bases |
|00004590| 63 61 6e 20 62 65 20 32 | 20 2d 20 33 36 2c 20 31 |can be 2| - 36, 1|
|000045a0| 30 30 30 30 2c 20 6f 72 | 20 30 2c 20 77 68 65 72 |0000, or| 0, wher|
|000045b0| 65 20 30 20 64 65 66 61 | 75 6c 74 73 20 74 6f 20 |e 0 defa|ults to |
|000045c0| 62 61 73 65 20 31 30 30 | 30 30 2e 0a 58 0a 58 20 |base 100|00..X.X |
|000045d0| 20 46 6f 72 20 65 78 61 | 6d 70 6c 65 2c 20 61 73 | For exa|mple, as|
|000045e0| 73 75 6d 65 20 74 68 61 | 74 20 77 65 20 77 61 6e |sume tha|t we wan|
|000045f0| 74 20 74 6f 20 61 73 73 | 69 67 6e 20 76 61 6c 75 |t to ass|ign valu|
|00004600| 65 73 20 74 6f 20 74 77 | 6f 20 70 72 65 76 69 6f |es to tw|o previo|
|00004610| 75 73 6c 79 0a 58 20 20 | 69 6e 69 74 69 61 6c 69 |usly.X |initiali|
|00004620| 7a 65 64 20 41 50 4d 20 | 65 6e 74 69 74 69 65 73 |zed APM |entities|
|00004630| 2c 20 61 70 6d 5f 31 20 | 61 6e 64 20 61 70 6d 5f |, apm_1 |and apm_|
|00004640| 32 2e 20 20 54 68 65 20 | 62 61 73 65 20 77 69 6c |2. The |base wil|
|00004650| 6c 20 62 65 20 62 61 73 | 65 20 31 30 30 30 30 2c |l be bas|e 10000,|
|00004660| 20 74 68 65 0a 58 20 20 | 66 69 72 73 74 20 76 61 | the.X |first va|
|00004670| 6c 75 65 20 77 69 6c 6c | 20 62 65 20 73 65 74 20 |lue will| be set |
|00004680| 74 6f 20 31 2e 32 33 34 | 35 36 20 61 6e 64 20 74 |to 1.234|56 and t|
|00004690| 68 65 20 73 65 63 6f 6e | 64 20 77 69 6c 6c 20 62 |he secon|d will b|
|000046a0| 65 20 73 65 74 20 74 6f | 20 31 20 45 32 30 20 28 |e set to| 1 E20 (|
|000046b0| 22 6f 6e 65 0a 58 20 20 | 74 69 6d 65 73 20 31 30 |"one.X |times 10|
|000046c0| 20 74 6f 20 74 68 65 20 | 32 30 74 68 20 70 6f 77 | to the |20th pow|
|000046d0| 65 72 22 29 3a 0a 58 0a | 58 20 20 20 20 20 20 69 |er"):.X.|X i|
|000046e0| 6e 74 20 65 72 63 6f 64 | 65 3b 0a 58 0a 58 20 20 |nt ercod|e;.X.X |
|000046f0| 20 20 20 20 65 72 63 6f | 64 65 20 3d 20 61 70 6d | erco|de = apm|
|00004700| 41 73 73 69 67 6e 4c 6f | 6e 67 28 61 70 6d 5f 31 |AssignLo|ng(apm_1|
|00004710| 2c 20 31 32 33 34 35 36 | 4c 2c 20 2d 35 2c 20 30 |, 123456|L, -5, 0|
|00004720| 29 3b 0a 58 20 20 20 20 | 20 20 2e 2e 2e 0a 58 0a |);.X | ....X.|
|00004730| 58 20 20 20 20 20 20 65 | 72 63 6f 64 65 20 3d 20 |X e|rcode = |
|00004740| 61 70 6d 41 73 73 69 67 | 6e 4c 6f 6e 67 28 61 70 |apmAssig|nLong(ap|
|00004750| 6d 5f 32 2c 20 31 4c 2c | 20 32 30 2c 20 30 29 3b |m_2, 1L,| 20, 0);|
|00004760| 0a 58 20 20 20 20 20 20 | 2e 2e 2e 0a 58 0a 58 20 |.X |....X.X |
|00004770| 20 54 68 65 20 72 65 74 | 75 72 6e 20 63 6f 64 65 | The ret|urn code|
|00004780| 20 61 6e 64 20 74 68 65 | 20 27 61 70 6d 5f 65 72 | and the| 'apm_er|
|00004790| 72 6e 6f 27 20 76 61 72 | 69 61 62 6c 65 20 72 65 |rno' var|iable re|
|000047a0| 66 6c 65 63 74 20 74 68 | 65 20 73 74 61 74 75 73 |flect th|e status|
|000047b0| 20 6f 66 20 74 68 69 73 | 0a 58 20 20 66 75 6e 63 | of this|.X func|
|000047c0| 74 69 6f 6e 2e 0a 58 0a | 58 69 6e 74 0a 58 61 70 |tion..X.|Xint.Xap|
|000047d0| 6d 41 73 73 69 67 6e 53 | 74 72 69 6e 67 28 61 70 |mAssignS|tring(ap|
|000047e0| 6d 2c 20 73 74 72 69 6e | 67 2c 20 62 61 73 65 29 |m, strin|g, base)|
|000047f0| 0a 58 41 50 4d 20 61 70 | 6d 3b 0a 58 63 68 61 72 |.XAPM ap|m;.Xchar|
|00004800| 20 2a 73 74 72 69 6e 67 | 3b 0a 58 73 68 6f 72 74 | *string|;.Xshort|
|00004810| 20 62 61 73 65 3b 0a 58 | 7b 7d 0a 58 20 20 54 68 | base;.X|{}.X Th|
|00004820| 69 73 20 72 6f 75 74 69 | 6e 65 20 74 61 6b 65 73 |is routi|ne takes|
|00004830| 20 61 20 63 68 61 72 61 | 63 74 65 72 20 73 74 72 | a chara|cter str|
|00004840| 69 6e 67 20 63 6f 6e 74 | 61 69 6e 69 6e 67 20 74 |ing cont|aining t|
|00004850| 68 65 20 41 53 43 49 49 | 20 72 65 70 72 65 73 65 |he ASCII| represe|
|00004860| 6e 74 61 74 69 6f 6e 20 | 6f 66 0a 58 20 20 61 20 |ntation |of.X a |
|00004870| 6e 75 6d 65 72 69 63 20 | 76 61 6c 75 65 20 61 6e |numeric |value an|
|00004880| 64 20 63 6f 6e 76 65 72 | 74 73 20 69 74 20 69 6e |d conver|ts it in|
|00004890| 74 6f 20 61 20 41 50 4d | 20 76 61 6c 75 65 20 69 |to a APM| value i|
|000048a0| 6e 20 74 68 65 20 62 61 | 73 65 20 73 70 65 63 69 |n the ba|se speci|
|000048b0| 66 69 65 64 2e 20 20 54 | 68 65 0a 58 20 20 27 61 |fied. T|he.X 'a|
|000048c0| 70 6d 27 20 70 61 72 61 | 6d 65 74 65 72 20 6d 75 |pm' para|meter mu|
|000048d0| 73 74 20 68 61 76 65 20 | 62 65 65 6e 20 70 72 65 |st have |been pre|
|000048e0| 76 69 6f 75 73 6c 79 20 | 69 6e 69 74 69 61 6c 69 |viously |initiali|
|000048f0| 7a 65 64 2c 20 27 73 74 | 72 69 6e 67 27 20 6d 75 |zed, 'st|ring' mu|
|00004900| 73 74 20 62 65 0a 58 20 | 20 6e 6f 6e 2d 4e 55 4c |st be.X | non-NUL|
|00004910| 4c 20 61 6e 64 20 76 61 | 6c 69 64 20 69 6e 20 74 |L and va|lid in t|
|00004920| 68 65 20 73 70 65 63 69 | 66 69 65 64 20 62 61 73 |he speci|fied bas|
|00004930| 65 2c 20 61 6e 64 20 27 | 62 61 73 65 27 20 6d 75 |e, and '|base' mu|
|00004940| 73 74 20 62 65 20 61 20 | 76 61 6c 69 64 20 62 61 |st be a |valid ba|
|00004950| 73 65 2e 0a 58 0a 58 20 | 20 54 68 65 20 72 65 74 |se..X.X | The ret|
|00004960| 75 72 6e 20 63 6f 64 65 | 20 61 6e 64 20 74 68 65 |urn code| and the|
|00004970| 20 27 61 70 6d 5f 65 72 | 72 6e 6f 27 20 76 61 72 | 'apm_er|rno' var|
|00004980| 69 61 62 6c 65 20 72 65 | 66 6c 65 63 74 20 74 68 |iable re|flect th|
|00004990| 65 20 73 74 61 74 75 73 | 20 6f 66 20 74 68 69 73 |e status| of this|
|000049a0| 0a 58 20 20 66 75 6e 63 | 74 69 6f 6e 2e 0a 58 0a |.X func|tion..X.|
|000049b0| 58 69 6e 74 0a 58 61 70 | 6d 43 6f 6e 76 65 72 74 |Xint.Xap|mConvert|
|000049c0| 28 73 74 72 69 6e 67 2c | 20 6c 65 6e 67 74 68 2c |(string,| length,|
|000049d0| 20 64 65 63 69 6d 61 6c | 73 2c 20 72 6f 75 6e 64 | decimal|s, round|
|000049e0| 2c 20 6c 65 66 74 6a 75 | 73 74 69 66 79 2c 20 61 |, leftju|stify, a|
|000049f0| 70 6d 29 0a 58 63 68 61 | 72 20 2a 73 74 72 69 6e |pm).Xcha|r *strin|
|00004a00| 67 3b 0a 58 69 6e 74 20 | 6c 65 6e 67 74 68 3b 0a |g;.Xint |length;.|
|00004a10| 58 69 6e 74 20 64 65 63 | 69 6d 61 6c 73 3b 0a 58 |Xint dec|imals;.X|
|00004a20| 69 6e 74 20 72 6f 75 6e | 64 3b 0a 58 69 6e 74 20 |int roun|d;.Xint |
|00004a30| 6c 65 66 74 6a 75 73 74 | 69 66 79 3b 0a 58 41 50 |leftjust|ify;.XAP|
|00004a40| 4d 20 61 70 6d 3b 0a 58 | 7b 7d 0a 58 20 20 54 68 |M apm;.X|{}.X Th|
|00004a50| 69 73 20 72 6f 75 74 69 | 6e 65 20 63 6f 6e 76 65 |is routi|ne conve|
|00004a60| 72 74 73 20 61 20 41 50 | 4d 20 76 61 6c 75 65 20 |rts a AP|M value |
|00004a70| 27 61 70 6d 27 20 69 6e | 74 6f 20 69 74 73 20 41 |'apm' in|to its A|
|00004a80| 53 43 49 49 20 72 65 70 | 72 65 73 65 6e 74 61 74 |SCII rep|resentat|
|00004a90| 69 6f 6e 0a 58 20 20 27 | 73 74 72 69 6e 67 27 2e |ion.X '|string'.|
|00004aa0| 20 54 68 65 20 27 6c 65 | 6e 67 74 68 27 20 70 61 | The 'le|ngth' pa|
|00004ab0| 72 61 6d 65 74 65 72 20 | 69 73 20 74 68 65 20 6d |rameter |is the m|
|00004ac0| 61 78 69 6d 75 6d 20 73 | 69 7a 65 20 6f 66 20 74 |aximum s|ize of t|
|00004ad0| 68 65 20 73 74 72 69 6e | 67 20 28 69 6e 63 6c 75 |he strin|g (inclu|
|00004ae0| 64 69 6e 67 0a 58 20 20 | 74 68 65 20 74 72 61 69 |ding.X |the trai|
|00004af0| 6c 69 6e 67 20 6e 75 6c | 6c 29 2c 20 74 68 65 20 |ling nul|l), the |
|00004b00| 27 64 65 63 69 6d 61 6c | 73 27 20 70 61 72 61 6d |'decimal|s' param|
|00004b10| 65 74 65 72 20 69 73 20 | 74 68 65 20 6e 75 6d 62 |eter is |the numb|
|00004b20| 65 72 20 6f 66 20 64 65 | 63 69 6d 61 6c 20 70 6c |er of de|cimal pl|
|00004b30| 61 63 65 73 0a 58 20 20 | 74 6f 20 64 69 73 70 6c |aces.X |to displ|
|00004b40| 61 79 2c 20 74 68 65 20 | 27 72 6f 75 6e 64 27 20 |ay, the |'round' |
|00004b50| 70 61 72 61 6d 65 74 65 | 72 20 69 73 20 61 20 74 |paramete|r is a t|
|00004b60| 72 75 65 2d 66 61 6c 73 | 65 20 76 61 6c 75 65 20 |rue-fals|e value |
|00004b70| 77 68 69 63 68 20 64 65 | 74 65 72 6d 69 6e 65 73 |which de|termines|
|00004b80| 0a 58 20 20 77 68 65 74 | 68 65 72 20 72 6f 75 6e |.X whet|her roun|
|00004b90| 64 69 6e 67 20 69 73 20 | 74 6f 20 74 61 6b 65 20 |ding is |to take |
|00004ba0| 70 6c 61 63 65 20 28 30 | 20 3d 20 66 61 6c 73 65 |place (0| = false|
|00004bb0| 20 3d 20 6e 6f 20 72 6f | 75 6e 64 69 6e 67 29 2c | = no ro|unding),|
|00004bc0| 20 74 68 65 0a 58 20 20 | 27 6c 65 66 74 6a 75 73 | the.X |'leftjus|
|00004bd0| 74 69 66 79 27 20 70 61 | 72 61 6d 65 74 65 72 20 |tify' pa|rameter |
|00004be0| 69 73 20 61 20 74 72 75 | 65 2d 66 61 6c 73 65 20 |is a tru|e-false |
|00004bf0| 76 61 6c 75 65 20 77 68 | 69 63 68 20 64 65 74 65 |value wh|ich dete|
|00004c00| 72 6d 69 6e 65 73 20 77 | 68 65 74 68 65 72 20 74 |rmines w|hether t|
|00004c10| 68 65 0a 58 20 20 72 65 | 73 75 6c 74 20 69 73 20 |he.X re|sult is |
|00004c20| 74 6f 20 62 65 20 6c 65 | 66 74 20 6a 75 73 74 69 |to be le|ft justi|
|00004c30| 66 69 65 64 20 28 30 20 | 3d 20 66 61 6c 73 65 20 |fied (0 |= false |
|00004c40| 3d 20 72 69 67 68 74 20 | 6a 75 73 74 69 66 79 3b |= right |justify;|
|00004c50| 20 6e 6f 6e 2d 7a 65 72 | 6f 20 3d 20 74 72 75 65 | non-zer|o = true|
|00004c60| 20 3d 0a 58 20 20 6c 65 | 66 74 20 6a 75 73 74 69 | =.X le|ft justi|
|00004c70| 66 79 29 2c 20 61 6e 64 | 20 74 68 65 20 27 61 70 |fy), and| the 'ap|
|00004c80| 6d 27 20 70 61 72 61 6d | 74 65 72 20 69 73 20 74 |m' param|ter is t|
|00004c90| 68 65 20 41 50 4d 20 76 | 61 6c 75 65 20 74 6f 20 |he APM v|alue to |
|00004ca0| 62 65 20 63 6f 6e 76 65 | 72 74 65 64 2e 0a 58 0a |be conve|rted..X.|
|00004cb0| 58 20 20 54 68 65 20 27 | 73 74 72 69 6e 67 27 20 |X The '|string' |
|00004cc0| 70 61 72 61 6d 65 74 65 | 72 20 6d 75 73 74 20 70 |paramete|r must p|
|00004cd0| 6f 69 6e 74 20 74 6f 20 | 61 6e 20 61 72 65 61 20 |oint to |an area |
|00004ce0| 74 68 61 74 20 63 61 6e | 20 68 6f 6c 64 20 61 74 |that can| hold at|
|00004cf0| 20 6c 65 61 73 74 20 27 | 6c 65 6e 67 74 68 27 0a | least '|length'.|
|00004d00| 58 20 20 62 79 74 65 73 | 2e 0a 58 0a 58 20 20 49 |X bytes|..X.X I|
|00004d10| 66 20 74 68 65 20 27 64 | 65 63 69 6d 61 6c 73 27 |f the 'd|ecimals'|
|00004d20| 20 70 61 72 61 6d 65 74 | 65 72 20 69 73 20 3c 20 | paramet|er is < |
|00004d30| 30 2c 20 74 68 65 20 73 | 74 72 69 6e 67 20 77 69 |0, the s|tring wi|
|00004d40| 6c 6c 20 63 6f 6e 74 61 | 69 6e 20 74 68 65 20 6e |ll conta|in the n|
|00004d50| 75 6d 62 65 72 20 6f 66 | 0a 58 20 20 64 65 63 69 |umber of|.X deci|
|00004d60| 6d 61 6c 20 70 6c 61 63 | 65 73 20 74 68 61 74 20 |mal plac|es that |
|00004d70| 61 72 65 20 69 6e 68 65 | 72 65 6e 74 20 69 6e 20 |are inhe|rent in |
|00004d80| 74 68 65 20 41 50 4d 20 | 76 61 6c 75 65 20 70 61 |the APM |value pa|
|00004d90| 73 73 65 64 20 69 6e 2e | 0a 58 0a 58 20 20 54 68 |ssed in.|.X.X Th|
|00004da0| 65 20 72 65 74 75 72 6e | 20 63 6f 64 65 20 61 6e |e return| code an|
|00004db0| 64 20 74 68 65 20 27 61 | 70 6d 5f 65 72 72 6e 6f |d the 'a|pm_errno|
|00004dc0| 27 20 76 61 72 69 61 62 | 6c 65 20 72 65 66 6c 65 |' variab|le refle|
|00004dd0| 63 74 20 74 68 65 20 73 | 74 61 74 75 73 20 6f 66 |ct the s|tatus of|
|00004de0| 20 74 68 69 73 0a 58 20 | 20 66 75 6e 63 74 69 6f | this.X | functio|
|00004df0| 6e 2e 0a 58 0a 58 69 6e | 74 0a 58 28 2a 61 70 6d |n..X.Xin|t.X(*apm|
|00004e00| 45 72 72 6f 72 46 75 6e | 63 28 6e 65 77 66 75 6e |ErrorFun|c(newfun|
|00004e10| 63 29 29 28 29 0a 58 69 | 6e 74 20 28 2a 6e 65 77 |c))().Xi|nt (*new|
|00004e20| 66 75 6e 63 29 28 29 3b | 0a 58 7b 7d 0a 58 20 20 |func)();|.X{}.X |
|00004e30| 54 68 69 73 20 72 6f 75 | 74 69 6e 65 20 72 65 67 |This rou|tine reg|
|00004e40| 69 73 74 65 72 73 20 61 | 6e 20 65 72 72 6f 72 20 |isters a|n error |
|00004e50| 68 61 6e 64 6c 65 72 20 | 66 6f 72 20 65 72 72 6f |handler |for erro|
|00004e60| 72 73 20 61 6e 64 20 77 | 61 72 6e 69 6e 67 73 2e |rs and w|arnings.|
|00004e70| 20 20 42 65 66 6f 72 65 | 20 61 6e 79 0a 58 20 20 | Before| any.X |
|00004e80| 6f 66 20 74 68 65 20 6f | 74 68 65 72 20 41 50 4d |of the o|ther APM|
|00004e90| 20 72 6f 75 74 69 6e 65 | 73 20 72 65 74 75 72 6e | routine|s return|
|00004ea0| 20 74 6f 20 74 68 65 20 | 63 61 6c 6c 65 72 2c 20 | to the |caller, |
|00004eb0| 61 6e 20 6f 70 74 69 6f | 6e 61 6c 20 65 72 72 6f |an optio|nal erro|
|00004ec0| 72 20 68 61 6e 64 6c 65 | 72 0a 58 20 20 73 70 65 |r handle|r.X spe|
|00004ed0| 63 69 66 69 65 64 20 69 | 6e 20 27 6e 65 77 66 75 |cified i|n 'newfu|
|00004ee0| 6e 63 27 20 63 61 6e 20 | 62 65 20 63 61 6c 6c 65 |nc' can |be calle|
|00004ef0| 64 20 74 6f 20 69 6e 74 | 65 72 63 65 70 74 20 74 |d to int|ercept t|
|00004f00| 68 65 20 72 65 73 75 6c | 74 20 6f 66 20 74 68 65 |he resul|t of the|
|00004f10| 0a 58 20 20 6f 70 65 72 | 61 74 69 6f 6e 2e 20 20 |.X oper|ation. |
|00004f20| 57 69 74 68 20 61 20 72 | 65 67 69 73 74 65 72 65 |With a r|egistere|
|00004f30| 64 20 65 72 72 6f 72 20 | 68 61 6e 64 6c 65 72 2c |d error |handler,|
|00004f40| 20 74 68 65 20 63 61 6c | 6c 65 72 20 63 61 6e 20 | the cal|ler can |
|00004f50| 64 69 73 70 65 6e 73 65 | 20 77 69 74 68 20 74 68 |dispense| with th|
|00004f60| 65 0a 58 20 20 72 65 70 | 65 74 69 74 69 6f 75 73 |e.X rep|etitious|
|00004f70| 20 63 6f 64 65 20 66 6f | 72 20 63 68 65 63 6b 69 | code fo|r checki|
|00004f80| 6e 67 20 27 61 70 6d 5f | 65 72 72 6e 6f 27 20 6f |ng 'apm_|errno' o|
|00004f90| 72 20 74 68 65 20 66 75 | 6e 63 74 69 6f 6e 20 72 |r the fu|nction r|
|00004fa0| 65 74 75 72 6e 20 73 74 | 61 74 75 73 20 61 66 74 |eturn st|atus aft|
|00004fb0| 65 72 0a 58 20 20 65 61 | 63 68 20 63 61 6c 6c 20 |er.X ea|ch call |
|00004fc0| 74 6f 20 61 20 41 50 4d | 20 72 6f 75 74 69 6e 65 |to a APM| routine|
|00004fd0| 2e 0a 58 0a 58 20 20 49 | 66 20 6e 6f 20 65 72 72 |..X.X I|f no err|
|00004fe0| 6f 72 20 68 61 6e 64 6c | 65 72 20 69 73 20 72 65 |or handl|er is re|
|00004ff0| 67 69 73 74 65 72 65 64 | 20 6f 72 20 69 66 20 27 |gistered| or if '|
|00005000| 6e 65 77 66 75 6e 63 27 | 20 69 73 20 73 65 74 20 |newfunc'| is set |
|00005010| 74 6f 20 4e 55 4c 4c 2c | 20 6e 6f 20 61 63 74 69 |to NULL,| no acti|
|00005020| 6f 6e 0a 58 20 20 77 69 | 6c 6c 20 62 65 20 74 61 |on.X wi|ll be ta|
|00005030| 6b 65 6e 20 6f 6e 20 65 | 72 72 6f 72 73 20 61 6e |ken on e|rrors an|
|00005040| 64 20 77 61 72 6e 69 6e | 67 73 20 65 78 63 65 70 |d warnin|gs excep|
|00005050| 74 20 74 6f 20 73 65 74 | 20 74 68 65 20 27 61 70 |t to set| the 'ap|
|00005060| 6d 5f 65 72 72 6e 6f 27 | 20 76 61 72 69 61 62 6c |m_errno'| variabl|
|00005070| 65 2e 0a 58 20 20 49 66 | 20 74 68 65 72 65 20 69 |e..X If| there i|
|00005080| 73 20 61 6e 20 65 72 72 | 6f 72 20 68 61 6e 64 6c |s an err|or handl|
|00005090| 65 72 2c 20 69 74 20 69 | 73 20 63 61 6c 6c 65 64 |er, it i|s called|
|000050a0| 20 61 73 20 66 6f 6c 6c | 6f 77 73 20 77 68 65 6e | as foll|ows when|
|000050b0| 20 74 68 65 72 65 20 69 | 73 20 61 6e 20 65 72 72 | there i|s an err|
|000050c0| 6f 72 0a 58 20 20 6f 72 | 20 61 20 77 61 72 6e 69 |or.X or| a warni|
|000050d0| 6e 67 3a 0a 58 0a 58 20 | 20 20 20 20 20 72 65 74 |ng:.X.X | ret|
|000050e0| 63 6f 64 65 20 3d 20 28 | 2a 6e 65 77 66 75 6e 63 |code = (|*newfunc|
|000050f0| 29 28 65 72 63 6f 64 65 | 2c 20 6d 65 73 73 61 67 |)(ercode|, messag|
|00005100| 65 2c 20 66 69 6c 65 2c | 20 6c 69 6e 65 2c 20 66 |e, file,| line, f|
|00005110| 75 6e 63 74 69 6f 6e 29 | 0a 58 0a 58 20 20 77 68 |unction)|.X.X wh|
|00005120| 65 72 65 20 2e 2e 2e 0a | 58 0a 58 20 20 20 20 20 |ere ....|X.X |
|00005130| 20 69 6e 74 20 72 65 74 | 63 6f 64 65 3b 20 20 09 | int ret|code; .|
|00005140| 2f 2a 20 72 65 74 75 72 | 6e 65 64 20 62 79 20 27 |/* retur|ned by '|
|00005150| 6e 65 77 66 75 6e 63 27 | 3a 20 73 68 6f 75 6c 64 |newfunc'|: should|
|00005160| 20 62 65 20 27 65 72 63 | 6f 64 65 27 20 2a 2f 0a | be 'erc|ode' */.|
|00005170| 58 20 20 20 20 20 20 69 | 6e 74 20 65 72 63 6f 64 |X i|nt ercod|
|00005180| 65 3b 20 20 20 09 2f 2a | 20 65 72 72 6f 72 20 63 |e; ./*| error c|
|00005190| 6f 64 65 20 2a 2f 0a 58 | 20 20 20 20 20 20 63 68 |ode */.X| ch|
|000051a0| 61 72 20 2a 6d 65 73 73 | 61 67 65 3b 09 2f 2a 20 |ar *mess|age;./* |
|000051b0| 61 20 73 68 6f 72 74 20 | 73 74 72 69 6e 67 20 64 |a short |string d|
|000051c0| 65 73 63 72 69 62 69 6e | 67 20 74 68 65 20 65 72 |escribin|g the er|
|000051d0| 72 6f 72 20 2a 2f 0a 58 | 20 20 20 20 20 20 63 68 |ror */.X| ch|
|000051e0| 61 72 20 2a 66 69 6c 65 | 3b 20 20 20 09 2f 2a 20 |ar *file|; ./* |
|000051f0| 74 68 65 20 66 69 6c 65 | 20 69 6e 20 77 68 69 63 |the file| in whic|
|00005200| 68 20 74 68 65 20 65 72 | 72 6f 72 20 6f 63 63 75 |h the er|ror occu|
|00005210| 72 72 65 64 20 2a 2f 0a | 58 20 20 20 20 20 20 69 |rred */.|X i|
|00005220| 6e 74 20 6c 69 6e 65 3b | 09 20 20 20 20 09 2f 2a |nt line;|. ./*|
|00005230| 20 74 68 65 20 6c 69 6e | 65 20 6f 6e 20 77 68 69 | the lin|e on whi|
|00005240| 63 68 20 74 68 65 20 65 | 72 72 6f 72 20 6f 63 63 |ch the e|rror occ|
|00005250| 75 72 72 65 64 20 2a 2f | 0a 58 20 20 20 20 20 20 |urred */|.X |
|00005260| 63 68 61 72 20 2a 66 75 | 6e 63 74 69 6f 6e 3b 09 |char *fu|nction;.|
|00005270| 2f 2a 20 74 68 65 20 6e | 61 6d 65 20 6f 66 20 74 |/* the n|ame of t|
|00005280| 68 65 20 66 75 6e 63 74 | 69 6f 6e 20 69 6e 20 65 |he funct|ion in e|
|00005290| 72 72 6f 72 20 2a 2f 0a | 58 0a 58 20 20 4e 6f 74 |rror */.|X.X Not|
|000052a0| 65 20 74 68 61 74 20 79 | 6f 75 72 20 65 72 72 6f |e that y|our erro|
|000052b0| 72 20 68 61 6e 64 6c 65 | 72 20 73 68 6f 75 6c 64 |r handle|r should|
|000052c0| 20 6e 6f 72 6d 61 6c 6c | 79 20 72 65 74 75 72 6e | normall|y return|
|000052d0| 20 27 65 72 63 6f 64 65 | 27 20 75 6e 6c 65 73 73 | 'ercode|' unless|
|000052e0| 20 69 74 20 64 6f 65 73 | 20 61 0a 58 20 20 6c 6f | it does| a.X lo|
|000052f0| 6e 67 6a 6d 70 2c 20 63 | 61 6c 6c 73 20 65 78 69 |ngjmp, c|alls exi|
|00005300| 74 28 29 2c 20 6f 72 20 | 69 6e 20 73 6f 6d 65 20 |t(), or |in some |
|00005310| 6f 74 68 65 72 20 77 61 | 79 20 69 6e 74 65 72 72 |other wa|y interr|
|00005320| 75 70 74 73 20 74 68 65 | 20 6e 6f 72 6d 61 6c 20 |upts the| normal |
|00005330| 70 72 6f 63 65 73 73 69 | 6e 67 0a 58 20 20 66 6c |processi|ng.X fl|
|00005340| 6f 77 2e 20 20 54 68 65 | 20 76 61 6c 75 65 20 72 |ow. The| value r|
|00005350| 65 74 75 72 6e 65 64 20 | 66 72 6f 6d 20 79 6f 75 |eturned |from you|
|00005360| 72 20 65 72 72 6f 72 20 | 68 61 6e 64 6c 65 72 20 |r error |handler |
|00005370| 69 73 20 74 68 65 20 76 | 61 6c 75 65 20 74 68 61 |is the v|alue tha|
|00005380| 74 20 74 68 65 20 61 70 | 6d 0a 58 20 20 72 6f 75 |t the ap|m.X rou|
|00005390| 74 69 6e 65 20 69 6e 20 | 65 72 72 6f 72 20 77 69 |tine in |error wi|
|000053a0| 6c 6c 20 72 65 74 75 72 | 6e 20 74 6f 20 69 74 73 |ll retur|n to its|
|000053b0| 20 63 61 6c 6c 65 72 2e | 0a 58 0a 58 20 20 54 68 | caller.|.X.X Th|
|000053c0| 65 20 65 72 72 6f 72 20 | 68 61 6e 64 6c 65 72 20 |e error |handler |
|000053d0| 69 73 20 63 61 6c 6c 65 | 64 20 61 66 74 65 72 20 |is calle|d after |
|000053e0| 27 61 70 6d 5f 65 72 72 | 6e 6f 27 20 69 73 20 73 |'apm_err|no' is s|
|000053f0| 65 74 2e 0a 58 0a 58 20 | 20 54 68 69 73 20 72 6f |et..X.X | This ro|
|00005400| 75 74 69 6e 65 20 72 65 | 74 75 72 6e 73 20 61 20 |utine re|turns a |
|00005410| 70 6f 69 6e 74 65 72 20 | 74 6f 20 74 68 65 20 70 |pointer |to the p|
|00005420| 72 65 76 69 6f 75 73 6c | 79 20 72 65 67 69 73 74 |reviousl|y regist|
|00005430| 65 72 65 64 20 65 72 72 | 6f 72 20 68 61 6e 64 6c |ered err|or handl|
|00005440| 65 72 20 6f 72 0a 58 20 | 20 4e 55 4c 4c 20 69 66 |er or.X | NULL if|
|00005450| 20 6f 6e 65 20 69 73 6e | 27 74 20 72 65 67 69 73 | one isn|'t regis|
|00005460| 74 65 72 65 64 2e 0a 58 | 0a 58 69 6e 74 0a 58 61 |tered..X|.Xint.Xa|
|00005470| 70 6d 43 61 6c 63 28 72 | 65 73 75 6c 74 2c 20 6f |pmCalc(r|esult, o|
|00005480| 70 65 72 61 6e 64 2c 20 | 2e 2e 2e 2c 20 4e 55 4c |perand, |..., NUL|
|00005490| 4c 29 0a 58 41 50 4d 20 | 72 65 73 75 6c 74 3b 0a |L).XAPM |result;.|
|000054a0| 58 41 50 4d 20 6f 70 65 | 72 61 6e 64 2c 20 2e 2e |XAPM ope|rand, ..|
|000054b0| 2e 3b 0a 58 7b 7d 0a 58 | 20 20 54 68 69 73 20 72 |.;.X{}.X| This r|
|000054c0| 6f 75 74 69 6e 65 20 70 | 65 72 66 6f 72 6d 73 20 |outine p|erforms |
|000054d0| 61 20 73 65 72 69 65 73 | 20 6f 66 20 63 61 6c 63 |a series| of calc|
|000054e0| 75 6c 61 74 69 6f 6e 73 | 20 69 6e 20 61 6e 20 52 |ulations| in an R|
|000054f0| 50 4e 20 28 22 52 65 76 | 65 72 73 65 0a 58 20 20 |PN ("Rev|erse.X |
|00005500| 50 6f 6c 69 73 68 20 4e | 6f 74 61 74 69 6f 6e 22 |Polish N|otation"|
|00005510| 29 20 66 61 73 68 69 6f | 6e 2c 20 72 65 74 75 72 |) fashio|n, retur|
|00005520| 6e 69 6e 67 20 74 68 65 | 20 66 69 6e 61 6c 20 72 |ning the| final r|
|00005530| 65 73 75 6c 74 20 69 6e | 20 74 68 65 20 27 72 65 |esult in| the 're|
|00005540| 73 75 6c 74 27 0a 58 20 | 20 76 61 72 69 61 62 6c |sult'.X | variabl|
|00005550| 65 2e 20 20 49 74 20 74 | 61 6b 65 73 20 61 20 76 |e. It t|akes a v|
|00005560| 61 72 69 61 62 6c 65 20 | 6e 75 6d 62 65 72 20 6f |ariable |number o|
|00005570| 66 20 61 72 67 75 6d 65 | 6e 74 73 20 61 6e 64 20 |f argume|nts and |
|00005580| 68 65 6e 63 65 20 74 68 | 65 0a 58 20 20 72 69 67 |hence th|e.X rig|
|00005590| 68 74 6d 6f 73 74 20 61 | 72 67 75 6d 65 6e 74 20 |htmost a|rgument |
|000055a0| 6d 75 73 74 20 62 65 20 | 61 20 4e 55 4c 4c 2e 0a |must be |a NULL..|
|000055b0| 58 0a 58 20 20 45 61 63 | 68 20 27 6f 70 65 72 61 |X.X Eac|h 'opera|
|000055c0| 6e 64 27 20 69 73 20 65 | 69 74 68 65 72 20 61 20 |nd' is e|ither a |
|000055d0| 41 50 4d 20 76 61 6c 75 | 65 20 6f 72 20 61 20 73 |APM valu|e or a s|
|000055e0| 70 65 63 69 61 6c 20 63 | 6f 6e 73 74 61 6e 74 20 |pecial c|onstant |
|000055f0| 69 6e 64 69 63 61 74 69 | 6e 67 0a 58 20 20 74 68 |indicati|ng.X th|
|00005600| 65 20 6f 70 65 72 61 74 | 69 6f 6e 20 74 68 61 74 |e operat|ion that|
|00005610| 20 69 73 20 74 6f 20 62 | 65 20 70 65 72 66 6f 72 | is to b|e perfor|
|00005620| 6d 65 64 20 28 73 65 65 | 20 62 65 6c 6f 77 29 2e |med (see| below).|
|00005630| 20 20 54 68 69 73 20 72 | 6f 75 74 69 6e 65 20 6d | This r|outine m|
|00005640| 61 6b 65 73 0a 58 20 20 | 75 73 65 20 6f 66 20 61 |akes.X |use of a|
|00005650| 20 73 74 61 63 6b 20 28 | 31 36 20 6c 65 76 65 6c | stack (|16 level|
|00005660| 73 20 64 65 65 70 29 20 | 73 69 6d 69 6c 61 72 20 |s deep) |similar |
|00005670| 74 6f 20 74 68 61 74 20 | 69 6e 20 6d 61 6e 79 20 |to that |in many |
|00005680| 70 6f 63 6b 65 74 0a 58 | 20 20 63 61 6c 63 75 6c |pocket.X| calcul|
|00005690| 61 74 6f 72 73 2e 20 20 | 49 74 20 61 6c 73 6f 20 |ators. |It also |
|000056a0| 69 73 20 61 62 6c 65 20 | 74 6f 20 61 63 63 65 73 |is able |to acces|
|000056b0| 73 20 61 20 73 65 74 20 | 6f 66 20 31 36 20 61 75 |s a set |of 16 au|
|000056c0| 78 69 6c 69 61 72 79 0a | 58 20 20 72 65 67 69 73 |xiliary.|X regis|
|000056d0| 74 65 72 73 20 28 6e 75 | 6d 62 65 72 65 64 20 30 |ters (nu|mbered 0|
|000056e0| 20 74 68 72 6f 75 67 68 | 20 31 35 29 20 66 6f 72 | through| 15) for|
|000056f0| 20 68 6f 6c 64 69 6e 67 | 20 69 6e 74 65 72 6d 65 | holding| interme|
|00005700| 64 69 61 74 65 20 76 61 | 6c 75 65 73 2e 0a 58 0a |diate va|lues..X.|
|00005710| 58 20 20 54 68 65 20 73 | 74 61 63 6b 20 67 65 74 |X The s|tack get|
|00005720| 73 20 72 65 69 6e 69 74 | 69 61 6c 69 7a 65 64 20 |s reinit|ialized |
|00005730| 61 74 20 74 68 65 20 73 | 74 61 72 74 20 6f 66 20 |at the s|tart of |
|00005740| 74 68 69 73 20 72 6f 75 | 74 69 6e 65 2c 20 73 6f |this rou|tine, so|
|00005750| 20 76 61 6c 75 65 73 0a | 58 20 20 74 68 61 74 20 | values.|X that |
|00005760| 68 61 76 65 20 62 65 65 | 6e 20 6c 65 66 74 20 6f |have bee|n left o|
|00005770| 6e 20 74 68 65 20 73 74 | 61 63 6b 20 66 72 6f 6d |n the st|ack from|
|00005780| 20 61 20 70 72 65 76 69 | 6f 75 73 20 63 61 6c 6c | a previ|ous call|
|00005790| 20 77 69 6c 6c 20 64 69 | 73 61 70 70 65 61 72 2e | will di|sappear.|
|000057a0| 0a 58 20 20 48 6f 77 65 | 76 65 72 2c 20 74 68 65 |.X Howe|ver, the|
|000057b0| 20 61 75 78 69 6c 69 61 | 72 79 20 72 65 67 69 73 | auxilia|ry regis|
|000057c0| 74 65 72 73 20 61 72 65 | 20 73 74 61 74 69 63 20 |ters are| static |
|000057d0| 61 6e 64 20 76 61 6c 75 | 65 73 20 72 65 6d 61 69 |and valu|es remai|
|000057e0| 6e 20 69 6e 20 74 68 65 | 73 65 0a 58 20 20 72 65 |n in the|se.X re|
|000057f0| 67 69 73 74 65 72 73 20 | 66 6f 72 20 74 68 65 20 |gisters |for the |
|00005800| 64 75 72 61 74 69 6f 6e | 20 6f 66 20 79 6f 75 72 |duration| of your|
|00005810| 20 70 72 6f 67 72 61 6d | 2e 20 20 54 68 65 79 20 | program|. They |
|00005820| 6d 61 79 20 61 6c 73 6f | 20 62 65 0a 58 20 20 72 |may also| be.X r|
|00005830| 65 74 72 69 65 76 65 64 | 20 6f 75 74 73 69 64 65 |etrieved| outside|
|00005840| 20 6f 66 20 74 68 69 73 | 20 72 6f 75 74 69 6e 65 | of this| routine|
|00005850| 20 28 73 65 65 20 74 68 | 65 20 61 70 6d 47 65 74 | (see th|e apmGet|
|00005860| 52 65 67 69 73 74 65 72 | 28 29 20 61 6e 64 0a 58 |Register|() and.X|
|00005870| 20 20 61 70 6d 53 65 74 | 52 65 67 69 73 74 65 72 | apmSet|Register|
|00005880| 28 29 20 72 6f 75 74 69 | 6e 65 73 2c 20 62 65 6c |() routi|nes, bel|
|00005890| 6f 77 29 2e 0a 58 0a 58 | 20 20 41 6e 20 6f 70 65 |ow)..X.X| An ope|
|000058a0| 72 61 6e 64 20 74 68 61 | 74 20 69 73 20 61 6e 20 |rand tha|t is an |
|000058b0| 41 50 4d 20 76 61 6c 75 | 65 20 69 73 20 61 75 74 |APM valu|e is aut|
|000058c0| 6f 6d 61 74 69 63 61 6c | 6c 79 20 70 75 73 68 65 |omatical|ly pushe|
|000058d0| 64 20 6f 6e 74 6f 20 74 | 68 65 20 73 74 61 63 6b |d onto t|he stack|
|000058e0| 0a 58 20 20 73 69 6d 70 | 6c 79 20 62 79 20 6e 61 |.X simp|ly by na|
|000058f0| 6d 69 6e 67 20 69 74 20 | 69 6e 20 74 68 65 20 66 |ming it |in the f|
|00005900| 75 6e 63 74 69 6f 6e 20 | 63 61 6c 6c 2e 20 20 49 |unction |call. I|
|00005910| 66 20 74 68 65 20 73 74 | 61 63 6b 20 69 73 20 66 |f the st|ack is f|
|00005920| 75 6c 6c 20 77 68 65 6e | 20 61 0a 58 20 20 76 61 |ull when| a.X va|
|00005930| 6c 75 65 20 69 73 20 62 | 65 69 6e 67 20 70 75 73 |lue is b|eing pus|
|00005940| 68 65 64 20 6f 6e 74 6f | 20 69 74 2c 20 74 68 65 |hed onto| it, the|
|00005950| 20 62 6f 74 74 6f 6d 6d | 6f 73 74 20 76 61 6c 75 | bottomm|ost valu|
|00005960| 65 20 64 72 6f 70 73 20 | 6f 66 66 20 74 68 65 0a |e drops |off the.|
|00005970| 58 20 20 73 74 61 63 6b | 20 61 6e 64 20 74 68 65 |X stack| and the|
|00005980| 20 70 75 73 68 20 73 75 | 63 63 65 65 64 73 3b 20 | push su|cceeds; |
|00005990| 74 68 69 73 20 69 73 20 | 73 69 6d 69 6c 61 72 20 |this is |similar |
|000059a0| 74 6f 20 68 6f 77 20 6d | 61 6e 79 20 70 6f 63 6b |to how m|any pock|
|000059b0| 65 74 0a 58 20 20 63 61 | 6c 63 75 6c 61 74 6f 72 |et.X ca|lculator|
|000059c0| 73 20 77 6f 72 6b 2e 20 | 20 41 6c 73 6f 2c 20 69 |s work. | Also, i|
|000059d0| 66 20 74 68 65 20 73 74 | 61 63 6b 20 69 73 20 65 |f the st|ack is e|
|000059e0| 6d 70 74 79 2c 20 61 20 | 70 6f 70 20 77 69 6c 6c |mpty, a |pop will|
|000059f0| 20 73 75 63 63 65 65 64 | 2c 0a 58 20 20 79 69 65 | succeed|,.X yie|
|00005a00| 6c 64 69 6e 67 20 61 20 | 7a 65 72 6f 20 76 61 6c |lding a |zero val|
|00005a10| 75 65 20 61 6e 64 20 6b | 65 65 70 69 6e 67 20 74 |ue and k|eeping t|
|00005a20| 68 65 20 73 74 61 63 6b | 20 65 6d 70 74 79 2e 20 |he stack| empty. |
|00005a30| 20 54 68 65 20 74 6f 70 | 6d 6f 73 74 20 76 61 6c | The top|most val|
|00005a40| 75 65 0a 58 20 20 6f 6e | 20 74 68 65 20 73 74 61 |ue.X on| the sta|
|00005a50| 63 6b 20 69 73 20 61 75 | 74 6f 6d 61 74 69 63 61 |ck is au|tomatica|
|00005a60| 6c 6c 79 20 70 6f 70 70 | 65 64 20 69 6e 74 6f 20 |lly popp|ed into |
|00005a70| 74 68 65 20 27 72 65 73 | 75 6c 74 27 20 70 61 72 |the 'res|ult' par|
|00005a80| 61 6d 65 74 65 72 20 61 | 66 74 65 72 0a 58 20 20 |ameter a|fter.X |
|00005a90| 61 6c 6c 20 74 68 65 20 | 6f 70 65 72 61 74 69 6f |all the |operatio|
|00005aa0| 6e 73 20 68 61 76 65 20 | 62 65 65 6e 20 70 65 72 |ns have |been per|
|00005ab0| 66 6f 72 6d 65 64 2e 0a | 58 0a 58 20 20 41 6e 20 |formed..|X.X An |
|00005ac0| 6f 70 65 72 61 6e 64 20 | 74 68 61 74 20 69 73 20 |operand |that is |
|00005ad0| 6f 6e 65 20 6f 66 20 74 | 68 65 20 66 6f 6c 6c 6f |one of t|he follo|
|00005ae0| 77 69 6e 67 20 73 70 65 | 63 69 61 6c 20 76 61 6c |wing spe|cial val|
|00005af0| 75 65 73 20 77 69 6c 6c | 20 63 61 75 73 65 0a 58 |ues will| cause.X|
|00005b00| 20 20 61 6e 20 6f 70 65 | 72 61 74 69 6f 6e 20 74 | an ope|ration t|
|00005b10| 6f 20 62 65 20 70 65 72 | 66 6f 72 6d 65 64 2e 20 |o be per|formed. |
|00005b20| 20 54 68 65 73 65 20 6f | 70 65 72 61 74 69 6f 6e | These o|peration|
|00005b30| 73 20 61 72 65 20 64 65 | 73 63 72 69 62 65 64 20 |s are de|scribed |
|00005b40| 69 6e 20 74 68 65 0a 58 | 20 20 66 6f 6c 6c 6f 77 |in the.X| follow|
|00005b50| 69 6e 67 20 6c 69 73 74 | 2e 20 20 4e 6f 74 65 20 |ing list|. Note |
|00005b60| 74 68 61 74 20 74 68 65 | 20 76 61 6c 75 65 73 20 |that the| values |
|00005b70| 22 56 22 2c 20 22 56 31 | 22 2c 20 61 6e 64 20 22 |"V", "V1|", and "|
|00005b80| 56 32 22 20 61 72 65 20 | 75 73 65 64 0a 58 20 20 |V2" are |used.X |
|00005b90| 69 6e 20 74 68 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |in the f|ollowing|
|00005ba0| 20 6c 69 73 74 20 74 6f | 20 73 74 61 6e 64 20 66 | list to| stand f|
|00005bb0| 6f 72 20 74 65 6d 70 6f | 72 61 72 79 20 76 61 6c |or tempo|rary val|
|00005bc0| 75 65 73 3a 0a 58 0a 58 | 09 41 50 4d 5f 41 42 53 |ues:.X.X|.APM_ABS|
|00005bd0| 09 09 70 6f 70 20 56 2c | 20 70 75 73 68 20 61 62 |..pop V,| push ab|
|00005be0| 73 6f 6c 75 74 65 20 76 | 61 6c 75 65 20 6f 66 20 |solute v|alue of |
|00005bf0| 56 0a 58 09 41 50 4d 5f | 4e 45 47 09 09 70 6f 70 |V.X.APM_|NEG..pop|
|00005c00| 20 56 2c 20 70 75 73 68 | 20 2d 56 0a 58 09 41 50 | V, push| -V.X.AP|
|00005c10| 4d 5f 43 4c 45 41 52 09 | 65 6d 70 74 79 20 74 68 |M_CLEAR.|empty th|
|00005c20| 65 20 73 74 61 63 6b 0a | 58 09 41 50 4d 5f 44 55 |e stack.|X.APM_DU|
|00005c30| 50 09 09 70 6f 70 20 56 | 2c 20 70 75 73 68 20 56 |P..pop V|, push V|
|00005c40| 2c 20 70 75 73 68 20 56 | 0a 58 09 41 50 4d 5f 53 |, push V|.X.APM_S|
|00005c50| 57 41 50 09 70 6f 70 20 | 56 31 2c 20 70 6f 70 20 |WAP.pop |V1, pop |
|00005c60| 56 32 2c 20 70 75 73 68 | 20 56 31 2c 20 70 75 73 |V2, push| V1, pus|
|00005c70| 68 20 56 32 0a 58 09 41 | 50 4d 5f 53 43 41 4c 45 |h V2.X.A|PM_SCALE|
|00005c80| 28 4e 29 09 70 6f 70 20 | 56 2c 20 70 75 73 68 20 |(N).pop |V, push |
|00005c90| 56 20 73 63 61 6c 65 64 | 20 62 79 20 4e 20 5b 20 |V scaled| by N [ |
|00005ca0| 61 73 20 69 6e 20 61 70 | 6d 53 63 61 6c 65 28 29 |as in ap|mScale()|
|00005cb0| 20 5d 0a 58 09 41 50 4d | 5f 50 55 53 48 28 4e 29 | ].X.APM|_PUSH(N)|
|00005cc0| 09 56 20 3d 20 76 61 6c | 75 65 20 69 6e 20 72 65 |.V = val|ue in re|
|00005cd0| 67 69 73 74 65 72 20 4e | 2c 20 70 75 73 68 20 56 |gister N|, push V|
|00005ce0| 0a 58 09 41 50 4d 5f 50 | 4f 50 28 4e 29 09 70 6f |.X.APM_P|OP(N).po|
|00005cf0| 70 20 56 2c 20 73 74 6f | 72 65 20 69 74 20 69 6e |p V, sto|re it in|
|00005d00| 20 72 65 67 69 73 74 65 | 72 20 4e 0a 58 09 41 50 | registe|r N.X.AP|
|00005d10| 4d 5f 41 44 44 09 09 70 | 6f 70 20 56 31 2c 20 70 |M_ADD..p|op V1, p|
|00005d20| 6f 70 20 56 32 2c 20 70 | 75 73 68 20 28 56 32 20 |op V2, p|ush (V2 |
|00005d30| 2b 20 56 31 29 0a 58 09 | 41 50 4d 5f 53 55 42 09 |+ V1).X.|APM_SUB.|
|00005d40| 09 70 6f 70 20 56 31 2c | 20 70 6f 70 20 56 32 2c |.pop V1,| pop V2,|
|00005d50| 20 70 75 73 68 20 28 56 | 32 20 2d 20 56 31 29 0a | push (V|2 - V1).|
|00005d60| 58 09 41 50 4d 5f 4d 55 | 4c 09 09 70 6f 70 20 56 |X.APM_MU|L..pop V|
|00005d70| 31 2c 20 70 6f 70 20 56 | 32 2c 20 70 75 73 68 20 |1, pop V|2, push |
|00005d80| 28 56 32 20 2a 20 56 31 | 29 0a 58 09 41 50 4d 5f |(V2 * V1|).X.APM_|
|00005d90| 44 49 56 28 4e 29 09 70 | 6f 70 20 56 31 2c 20 70 |DIV(N).p|op V1, p|
|00005da0| 6f 70 20 56 32 2c 20 70 | 75 73 68 20 28 56 32 20 |op V2, p|ush (V2 |
|00005db0| 2f 20 56 31 29 20 77 69 | 74 68 20 4e 20 72 61 64 |/ V1) wi|th N rad|
|00005dc0| 69 78 20 70 6c 61 63 65 | 73 0a 58 09 09 09 5b 20 |ix place|s.X...[ |
|00005dd0| 61 73 20 69 6e 20 61 70 | 6d 44 69 76 69 64 65 28 |as in ap|mDivide(|
|00005de0| 29 20 5d 2c 20 72 65 6d | 61 69 6e 64 65 72 20 67 |) ], rem|ainder g|
|00005df0| 6f 65 73 20 69 6e 74 6f | 20 72 65 67 69 73 74 65 |oes into| registe|
|00005e00| 72 20 30 0a 58 09 41 50 | 4d 5f 52 45 43 49 50 28 |r 0.X.AP|M_RECIP(|
|00005e10| 4e 29 09 70 6f 70 20 56 | 2c 20 70 75 73 68 20 31 |N).pop V|, push 1|
|00005e20| 2f 56 20 77 69 74 68 20 | 4e 20 72 61 64 69 78 20 |/V with |N radix |
|00005e30| 70 6c 61 63 65 73 0a 58 | 09 09 09 5b 20 61 73 20 |places.X|...[ as |
|00005e40| 69 6e 20 61 70 6d 52 65 | 63 69 70 72 6f 63 61 6c |in apmRe|ciprocal|
|00005e50| 28 29 20 5d 0a 58 0a 58 | 20 20 53 69 6e 63 65 20 |() ].X.X| Since |
|00005e60| 72 65 67 69 73 74 65 72 | 20 30 20 69 73 20 75 73 |register| 0 is us|
|00005e70| 65 64 20 74 6f 20 68 6f | 6c 64 20 74 68 65 20 72 |ed to ho|ld the r|
|00005e80| 65 6d 61 69 6e 64 65 72 | 20 69 6e 20 61 20 64 69 |emainder| in a di|
|00005e90| 76 69 73 69 6f 6e 2c 20 | 69 74 20 69 73 0a 58 20 |vision, |it is.X |
|00005ea0| 20 72 65 63 6f 6d 6d 65 | 6e 64 65 64 20 74 68 61 | recomme|nded tha|
|00005eb0| 74 20 74 68 69 73 20 72 | 65 67 69 73 74 65 72 20 |t this r|egister |
|00005ec0| 6e 6f 74 20 62 65 20 75 | 73 65 64 20 74 6f 20 68 |not be u|sed to h|
|00005ed0| 6f 6c 64 20 6f 74 68 65 | 72 20 76 61 6c 75 65 73 |old othe|r values|
|00005ee0| 2e 0a 58 0a 58 20 20 41 | 73 20 61 6e 20 65 78 61 |..X.X A|s an exa|
|00005ef0| 6d 70 6c 65 2c 20 61 73 | 73 75 6d 65 20 74 68 61 |mple, as|sume tha|
|00005f00| 74 20 41 50 4d 20 76 61 | 6c 75 65 73 20 22 66 6f |t APM va|lues "fo|
|00005f10| 6f 22 2c 20 22 62 61 72 | 22 2c 20 61 6e 64 20 22 |o", "bar|", and "|
|00005f20| 62 61 7a 22 20 68 61 76 | 65 0a 58 20 20 62 65 65 |baz" hav|e.X bee|
|00005f30| 6e 20 69 6e 69 74 69 61 | 6c 69 7a 65 64 20 76 69 |n initia|lized vi|
|00005f40| 61 20 61 70 6d 49 6e 69 | 74 28 29 20 61 6e 64 20 |a apmIni|t() and |
|00005f50| 74 68 61 74 20 22 66 6f | 6f 22 20 61 6e 64 20 22 |that "fo|o" and "|
|00005f60| 62 61 72 22 20 61 72 65 | 20 74 6f 20 62 65 20 75 |bar" are| to be u|
|00005f70| 73 65 64 0a 58 20 20 74 | 6f 20 63 61 6c 63 75 6c |sed.X t|o calcul|
|00005f80| 61 74 65 20 22 62 61 7a | 22 20 61 73 20 66 6f 6c |ate "baz|" as fol|
|00005f90| 6c 6f 77 73 20 28 61 73 | 73 75 6d 65 20 74 68 61 |lows (as|sume tha|
|00005fa0| 74 20 64 69 76 69 73 69 | 6f 6e 73 20 73 74 6f 70 |t divisi|ons stop|
|00005fb0| 20 61 66 74 65 72 20 31 | 36 0a 58 20 20 64 65 63 | after 1|6.X dec|
|00005fc0| 69 6d 61 6c 20 70 6c 61 | 63 65 73 20 68 61 76 65 |imal pla|ces have|
|00005fd0| 20 62 65 65 6e 20 63 61 | 6c 63 6c 75 61 74 65 64 | been ca|lcluated|
|00005fe0| 29 3a 0a 58 0a 58 09 62 | 61 7a 20 3d 20 31 20 2f |):.X.X.b|az = 1 /|
|00005ff0| 20 28 28 28 28 66 6f 6f | 20 2a 20 62 61 72 29 20 | ((((foo| * bar) |
|00006000| 2b 20 66 6f 6f 29 20 2f | 20 62 61 72 29 20 2d 20 |+ foo) /| bar) - |
|00006010| 66 6f 6f 29 0a 58 0a 58 | 20 20 54 68 65 20 66 75 |foo).X.X| The fu|
|00006020| 6e 63 74 69 6f 6e 20 63 | 61 6c 6c 20 77 69 6c 6c |nction c|all will|
|00006030| 20 62 65 3a 0a 58 0a 58 | 09 62 63 64 43 61 6c 63 | be:.X.X|.bcdCalc|
|00006040| 28 62 61 7a 2c 20 66 6f | 6f 2c 20 41 50 4d 5f 44 |(baz, fo|o, APM_D|
|00006050| 55 50 2c 20 41 50 4d 5f | 50 4f 50 28 31 29 2c 20 |UP, APM_|POP(1), |
|00006060| 62 61 72 2c 20 41 50 4d | 5f 44 55 50 2c 20 41 50 |bar, APM|_DUP, AP|
|00006070| 4d 5f 50 4f 50 28 32 29 | 2c 0a 58 09 09 41 50 4d |M_POP(2)|,.X..APM|
|00006080| 5f 4d 55 4c 2c 20 41 50 | 4d 5f 50 55 53 48 28 31 |_MUL, AP|M_PUSH(1|
|00006090| 29 2c 20 41 50 4d 5f 41 | 44 44 2c 20 41 50 4d 5f |), APM_A|DD, APM_|
|000060a0| 50 55 53 48 28 32 29 2c | 20 41 50 4d 5f 44 49 56 |PUSH(2),| APM_DIV|
|000060b0| 28 31 36 29 2c 0a 58 09 | 09 41 50 4d 5f 50 55 53 |(16),.X.|.APM_PUS|
|000060c0| 48 28 31 29 2c 20 41 50 | 4d 5f 53 55 42 2c 20 41 |H(1), AP|M_SUB, A|
|000060d0| 50 4d 5f 52 45 43 49 50 | 28 31 36 29 2c 20 4e 55 |PM_RECIP|(16), NU|
|000060e0| 4c 4c 29 3b 0a 58 0a 58 | 20 20 4e 6f 74 65 20 74 |LL);.X.X| Note t|
|000060f0| 68 61 74 20 74 68 65 20 | 76 61 6c 75 65 20 6f 66 |hat the |value of|
|00006100| 20 22 66 6f 6f 22 20 69 | 73 20 73 74 6f 72 65 64 | "foo" i|s stored|
|00006110| 20 69 6e 20 72 65 67 69 | 73 74 65 72 20 31 20 61 | in regi|ster 1 a|
|00006120| 6e 64 20 74 68 65 20 76 | 61 6c 75 65 20 6f 66 0a |nd the v|alue of.|
|00006130| 58 20 20 22 62 61 72 22 | 20 69 73 20 73 74 6f 72 |X "bar"| is stor|
|00006140| 65 64 20 69 6e 20 72 65 | 67 69 73 74 65 72 20 32 |ed in re|gister 2|
|00006150| 2e 20 20 41 66 74 65 72 | 20 74 68 69 73 20 63 61 |. After| this ca|
|00006160| 6c 6c 2c 20 74 68 65 73 | 65 20 72 65 67 69 73 74 |ll, thes|e regist|
|00006170| 65 72 73 20 77 69 6c 6c | 0a 58 20 20 73 74 69 6c |ers will|.X stil|
|00006180| 6c 20 63 6f 6e 74 61 69 | 6e 20 74 68 6f 73 65 20 |l contai|n those |
|00006190| 76 61 6c 75 65 73 2e 0a | 58 0a 58 69 6e 74 0a 58 |values..|X.Xint.X|
|000061a0| 61 70 6d 47 65 74 52 65 | 67 69 73 74 65 72 28 72 |apmGetRe|gister(r|
|000061b0| 65 67 76 61 6c 75 65 2c | 20 72 65 67 6e 75 6d 62 |egvalue,| regnumb|
|000061c0| 65 72 29 0a 58 41 50 4d | 20 72 65 67 76 61 6c 75 |er).XAPM| regvalu|
|000061d0| 65 3b 0a 58 69 6e 74 20 | 72 65 67 6e 75 6d 62 65 |e;.Xint |regnumbe|
|000061e0| 72 3b 0a 58 7b 7d 0a 58 | 20 20 54 68 65 20 76 61 |r;.X{}.X| The va|
|000061f0| 6c 75 65 20 69 6e 20 61 | 75 78 69 6c 69 61 72 79 |lue in a|uxiliary|
|00006200| 20 72 65 67 69 73 74 65 | 72 20 6e 75 6d 62 65 72 | registe|r number|
|00006210| 20 27 72 65 67 6e 75 6d | 62 65 72 27 20 69 73 20 | 'regnum|ber' is |
|00006220| 61 73 73 69 67 6e 65 64 | 20 74 6f 20 41 50 4d 0a |assigned| to APM.|
|00006230| 58 20 20 76 61 6c 75 65 | 20 27 72 65 67 76 61 6c |X value| 'regval|
|00006240| 75 65 27 2e 20 20 54 68 | 65 20 27 72 65 67 6e 75 |ue'. Th|e 'regnu|
|00006250| 6d 62 65 72 27 20 70 61 | 72 61 6d 65 74 65 72 20 |mber' pa|rameter |
|00006260| 6d 75 73 74 20 62 65 20 | 62 65 74 77 65 65 6e 20 |must be |between |
|00006270| 30 20 61 6e 64 20 31 35 | 2c 0a 58 20 20 69 6e 63 |0 and 15|,.X inc|
|00006280| 6c 75 73 69 76 65 2e 20 | 20 54 68 65 20 27 72 65 |lusive. | The 're|
|00006290| 67 76 61 6c 75 65 27 20 | 70 61 72 61 6d 65 74 65 |gvalue' |paramete|
|000062a0| 72 20 6d 75 73 74 20 68 | 61 76 65 20 62 65 65 6e |r must h|ave been|
|000062b0| 20 70 72 65 76 69 6f 75 | 73 6c 79 0a 58 20 20 69 | previou|sly.X i|
|000062c0| 6e 69 74 69 61 6c 69 7a | 65 64 20 76 69 61 20 61 |nitializ|ed via a|
|000062d0| 70 6d 49 6e 69 74 28 29 | 2e 0a 58 0a 58 69 6e 74 |pmInit()|..X.Xint|
|000062e0| 0a 58 61 70 6d 53 65 74 | 52 65 67 69 73 74 65 72 |.XapmSet|Register|
|000062f0| 28 72 65 67 76 61 6c 75 | 65 2c 20 72 65 67 6e 75 |(regvalu|e, regnu|
|00006300| 6d 62 65 72 2c 20 6e 65 | 77 76 61 6c 75 65 29 0a |mber, ne|wvalue).|
|00006310| 58 41 50 4d 20 72 65 67 | 76 61 6c 75 65 3b 0a 58 |XAPM reg|value;.X|
|00006320| 69 6e 74 20 72 65 67 6e | 75 6d 62 65 72 3b 0a 58 |int regn|umber;.X|
|00006330| 41 50 4d 20 6e 65 77 76 | 61 6c 75 65 3b 0a 58 7b |APM newv|alue;.X{|
|00006340| 7d 0a 58 20 20 54 68 65 | 20 76 61 6c 75 65 20 69 |}.X The| value i|
|00006350| 6e 20 61 75 78 69 6c 69 | 61 72 79 20 72 65 67 69 |n auxili|ary regi|
|00006360| 73 74 65 72 20 6e 75 6d | 62 65 72 20 27 72 65 67 |ster num|ber 'reg|
|00006370| 6e 75 6d 62 65 72 27 20 | 69 73 20 61 73 73 69 67 |number' |is assig|
|00006380| 6e 65 64 20 74 6f 20 41 | 50 4d 0a 58 20 20 76 61 |ned to A|PM.X va|
|00006390| 6c 75 65 20 27 72 65 67 | 76 61 6c 75 65 27 2c 20 |lue 'reg|value', |
|000063a0| 61 6e 64 20 74 68 65 6e | 20 74 68 65 20 41 50 4d |and then| the APM|
|000063b0| 20 76 61 6c 75 65 20 27 | 6e 65 77 76 61 6c 75 65 | value '|newvalue|
|000063c0| 27 20 69 73 20 73 74 6f | 72 65 64 20 69 6e 20 74 |' is sto|red in t|
|000063d0| 68 61 74 0a 58 20 20 73 | 61 6d 65 20 72 65 67 69 |hat.X s|ame regi|
|000063e0| 73 74 65 72 2e 20 20 54 | 68 65 20 27 72 65 67 6e |ster. T|he 'regn|
|000063f0| 75 6d 62 65 72 27 20 70 | 61 72 61 6d 65 74 65 72 |umber' p|arameter|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.