home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / ieee / part1 next >
Encoding:
Internet Message Format  |  1986-11-30  |  18.0 KB

  1. From: genrad!decvax!decwrl!sun!dgh!dgh (David Hough)
  2. Subject: Announcement, README, Makefile for IEEE calculator
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 3, Issue 3
  7. Submitted by: decvax!decwrl!sun!dgh!dgh (David Hough)
  8.  
  9. #! /bin/sh
  10. : make a directory, cd to it, and run this through sh
  11. echo If this kit is complete, "End of Kit" will echo at the end
  12. echo Extracting announcement
  13. cat >announcement <<'End-Of-File'
  14. .de p
  15. .PP
  16. ..
  17. .de ts
  18. .ds CH \\$1
  19. .ds RH %
  20. .ds LH D. Hough
  21. .ds LF \\$3
  22. .ds CF
  23. .ds RF \\$2
  24. .TL
  25. \\$1
  26. .AU
  27. David Hough
  28. ..
  29. .ce
  30. Calculator for IEEE Floating Point Arithmetic
  31. .p
  32. Now that there is an approved IEEE standard for binary floating point
  33. arithmetic, persons interested in implementing the standard may be interested to
  34. learn of a software implementation of the standard available in the public domain.
  35. This implementation, called the IEEE calculator, provides a way to test 
  36. your implementation in progress against a fairly complete implementation of the 
  37. standard as it was specified in 1980.  
  38. The IEEE calculator allows one to enter numbers in
  39. decimal or hex notation, perform any of the operations specified by the standard, and
  40. view the numerical results in decimal and hex as well as the exceptions signalled.
  41. .p
  42. The IEEE calculator is written entirely in Pascal and computes results a bit at
  43. a time.  Consequently the arithmetic is too slow to use for any significant 
  44. number of calculations but is ideal for debugging new implementations by providing
  45. a comparison for results and exceptions.
  46. .p
  47. As public domain software the IEEE calculator is completely unsupported;
  48. users bear the entire responsibility for determining its correctness for
  49. and applicability to any specific purpose.  The program implements the standard
  50. as specified in 1980, but most subsequent changes in the standard are minor.
  51. .p
  52. Source code for 
  53. the IEEE calculator will be published on USENET, the Unix network,
  54. in the newsgroup mod.sources, shortly after this announcement appears.
  55. End-Of-File
  56. echo Extracting ANNOUNCEMENT
  57. cat >ANNOUNCEMENT <<'End-Of-File'
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.        Calculator for IEEE Floating Point Arithmetic
  65.  
  66.      Now that there is an approved IEEE standard for  binary
  67. floating  point arithmetic, persons interested in implement-
  68. ing the standard may be interested to learn  of  a  software
  69. implementation  of  the  standard  available  in  the public
  70. domain.  This implementation, called  the  IEEE  calculator,
  71. provides  a  way  to  test  your  implementation in progress
  72. against a fairly complete implementation of the standard  as
  73. it  was specified in 1980. The IEEE calculator allows one to
  74. enter numbers in decimal or hex notation, perform any of the
  75. operations specified by the standard, and view the numerical
  76. results in decimal and hex as well as  the  exceptions  sig-
  77. nalled.
  78.  
  79.      The IEEE calculator is written entirely in  Pascal  and
  80. computes  results  a bit at a time.  Consequently the arith-
  81. metic is too slow to use for any significant number of  cal-
  82. culations  but is ideal for debugging new implementations by
  83. providing a comparison for results and exceptions.
  84.  
  85.      As public domain software the IEEE calculator  is  com-
  86. pletely  unsupported;  users  bear the entire responsibility
  87. for determining its correctness for and applicability to any
  88. specific  purpose.   The  program implements the standard as
  89. specified in 1980, but most subsequent changes in the  stan-
  90. dard are minor.
  91.  
  92.      Source code for the IEEE calculator will  be  published
  93. on  USENET,  the Unix network, in the newsgroup mod.sources,
  94. shortly after this announcement appears.
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.                      September 2, 1985
  122.  
  123.  
  124. End-Of-File
  125. echo Extracting readme
  126. cat >readme <<'End-Of-File'
  127. .de p
  128. .PP
  129. ..
  130. .de ts
  131. .ds CH \\$1
  132. .ds RH %
  133. .ds LH D. Hough
  134. .ds LF \\$3
  135. .ds CF Company Confidential
  136. .ds RF \\$2
  137. .TL
  138. \\$1
  139. .AU
  140. David Hough
  141. ..
  142. .ce
  143. Test Calculator for IEEE Floating Point Arithmetic
  144. .p
  145. The IEEE Calculator is a program for testing an implementation of the
  146. IEEE Standard for Binary Floating-Point Arithmetic, drafted by IEEE
  147. Working Group P754, and adopted by the IEEE in 1985.
  148. It is primarily intended for the use of implementers in testing and
  149. checking their work.
  150. .p
  151. NOTICE:
  152. The IEEE Calculator was developed at Apple Computer in 1980 and modified
  153. only slightly since then, although the IEEE standard has changed
  154. somewhat since its 1980 draft.  Apple Computer has donated the program to
  155. the public domain.  Consequently any person may use the program as
  156. a public domain program, but in doing so takes the entire responsibility
  157. for determining its appropriateness and correctness for any particular
  158. use.  Neither the author, nor Apple Computer, nor the IEEE support the 
  159. program or warrant it to be applicable or correct for any
  160. particular purpose.
  161. .sp 2
  162. .ce
  163. Use
  164. .p
  165. COMMANDS:
  166. The IEEE calculator works like a reverse-Polish notation calculator.
  167. Operands are entered, then commands.  A particular entry is first
  168. checked against the list of commands; if not a command, then it is
  169. tested as a possible decimal number; then as a possible hex number.
  170. .p
  171. Multiple commands and operands may be entered on one line, separated
  172. by semicolons:
  173. .nf
  174.     Command:    2;sqrt;1;-
  175. .fi
  176. computes sqrt(2)-1 = .414...
  177. .p
  178. STACK:
  179. Operands are pushed on a stack, and popped as they are consumed
  180. by commands, which then push their results on the stack.
  181. In the example above, if the stack was empty at
  182. first, then it would contain only the result .414... at the end.
  183. .p
  184. When a new value is pushed on the stack, it is displayed in decimal
  185. and hex floating point format.  If any IEEE exception flags were
  186. raised by the command that created the value, then they are displayed.
  187. Abbreviations used are IV, OV, UN, D0, NO, and NX, for integer overflow,
  188. floating point overflow, underflow, divide by zero, invalid operation,
  189. and inexact result.
  190. .p
  191. DATA TYPES:
  192. Stack entries are kept in an unrounded extended format.   The unrounding
  193. means that the round and sticky bits are visible in the hex format.
  194. There are commands available to cause stack entries to be kept in
  195. single, double, or rounded extended precision.
  196. .p
  197. HEX FLOATING POINT:
  198. Stack entries are displayed in and may be entered in a hex floating
  199. point notation, consiting of hex digits followed by a decimal exponent.
  200. Thus
  201. .nf
  202.     1
  203.     1H
  204.     .8h1
  205.     40h-6
  206. .fill
  207. are all ways of entering 1.0.  Note that 100h100 means 256.0 * 2**100,
  208. NOT 256.0 * 2**256!
  209. .p
  210. TESTING:
  211. The command TEST places the calculator in a mode for performing
  212. each computation twice, once with its built in arithmetic and
  213. once with a user-defined arithmetic to be tested.  For each
  214. computational command, results and exception flags are computed
  215. both ways and compared.
  216. .sp 2
  217. .ce
  218. Setting up the IEEE Calculator
  219. .p
  220. The Calculator is distributed on USENET as a series of SHAR files.
  221. When run, these create the necessary source files in a directory.
  222. One of these files is a Makefile which can be used to make three
  223. versions of the calculator.
  224. The calctest version does NOT test any user-defined arithmetic.
  225. Calc 32 and calc64 test single and double precision
  226. floating point arithmetic in the Pascal compiler pc contained in
  227. Release 2.0 of Sun Unix.  These programs operate the same except when
  228. in TEST mode.
  229. .p
  230. Getting the calculator to work in other environments is primarily
  231. a matter of setting up the interface to the arithmetic to be tested.
  232. This is a system-dependent matter, so have fun.  
  233. .p
  234. If it is desired to get the program operational for its own sake
  235. without any intent to test a local IEEE implementation, modify the
  236. Makefile to only create calctest.
  237. .sp 2
  238. .ce
  239. Commands
  240. .p
  241. Authoritative information on commands is to be gleaned, in the best
  242. Unix tradition, from detailed examination of the source code.
  243. .nf
  244. TEST    toggle mode to test user-supplied arithmetic
  245. EXIT    quit the program
  246.  
  247. STOX80    change calculator storage mode to rounded extended
  248. STOF64    change calculator storage mode to IEEE double precision
  249. STOF32    change calculator storage mode to IEEE single precision
  250. STOI64    change calculator storage mode to 64 bit 2's complement integer
  251. STOI32    change calculator storage mode to 32 bit 2's complement integer
  252. STOI16    change calculator storage mode to 16 bit 2's complement integer
  253. UNROUNDED change calculator storage mode to unrounded extended (default)
  254.     also change calculator rounding precision mode to 80 significant bits
  255. R24    change calculator rounding precision mode to 24 significant bits
  256. R53    change calculator rounding precision mode to 53 significant bits
  257. RN    change calculator rounding mode to round to nearest (default)
  258. RM    change calculator rounding mode to round toward minus infinity
  259. RP    change calculator rounding mode to round toward plus infinity
  260. RZ    change calculator rounding mode to round toward zero
  261. AFF    change calculator infinity mode to affine (default)
  262. PROJ    change calculator infinity mode to projective
  263. NORM    change calculator subnormal mode to normalizing (default)
  264. WARN    change calculator subnormal mode to warning
  265. IV OV UN D0 NO NX
  266.     toggle the trap-enable for the corresponding exception
  267.     default is disabled
  268.  
  269. CLEAR    clear stack
  270. CRUNCH    clear stack except for top two entries
  271. DUP    pop x, then push it twice
  272. DUMP    print out contents of entire stack
  273. POP    pop one operand
  274. REV    pop x and y, push in reverse order
  275. E    push an extended approximation to e
  276. PI    push an extended approximation to pi
  277.  
  278. ABS    pop operand x, push abs(x)
  279. NEG    pop x, push -x
  280. SQRT    pop x, push sqrt(x)
  281. TOF32    pop x, convert to IEEE single precision, push
  282. TOF64    pop x, convert to IEEE double precision, push
  283. TOX80    pop x, convert to rounded extended precision, push
  284. TOF32I    pop x, convert to IEEE single integral value, push
  285. TOF64I    pop x, convert to IEEE double integral value, push
  286. TOX80I    pop x, convert to extended integral value, push
  287. TOI16    pop x, convert to 16 bit 2's complement integer, push
  288. TOI32    pop x, convert to 32 bit 2's complement integer, push
  289. TOI64    pop x, convert to 64 bit 2's complement integer, push
  290.  
  291. +    pop two operands, add, push result
  292. -    pop two operands, sub, push result
  293. *    pop two operands, mul, push result
  294. /    pop two operands, div, push result
  295. COMPARE pop x and y, push numerical result of comparison
  296. DIV    pop x and y, push integral quotient
  297. REM    pop x and y, push IEEE remainder from integral quotient
  298.  
  299. LOGB    an IEEE appendix function, logb
  300. NEXT    an IEEE appendix function, nextafter
  301. SCALE    an IEEE appendix function, scalb
  302. .fi
  303. End-Of-File
  304. echo Extracting README
  305. cat >README <<'End-Of-File'
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.      Test Calculator for IEEE Floating Point Arithmetic
  313.  
  314.      The IEEE Calculator is a program for testing an  imple-
  315. mentation  of  the  IEEE  Standard for Binary Floating-Point
  316. Arithmetic, drafted by IEEE Working Group P754, and  adopted
  317. by  the  IEEE in 1985.  It is primarily intended for the use
  318. of implementers in testing and checking their work.
  319.  
  320.      NOTICE: The IEEE Calculator was developed at Apple Com-
  321. puter  in  1980  and  modified  only  slightly  since  then,
  322. although the IEEE standard has changed  somewhat  since  its
  323. 1980  draft.   Apple Computer has donated the program to the
  324. public domain.  Consequently any person may use the  program
  325. as a public domain program, but in doing so takes the entire
  326. responsibility  for  determining  its  appropriateness   and
  327. correctness for any particular use.  Neither the author, nor
  328. Apple Computer, nor the IEEE support the program or  warrant
  329. it to be applicable or correct for any particular purpose.
  330.  
  331.  
  332.                             Use
  333.  
  334.      COMMANDS: The IEEE calculator  works  like  a  reverse-
  335. Polish notation calculator.  Operands are entered, then com-
  336. mands.  A particular entry is first checked against the list
  337. of commands; if not a command, then it is tested as a possi-
  338. ble decimal number; then as a possible hex number.
  339.  
  340.      Multiple commands and operands may be  entered  on  one
  341. line, separated by semicolons:
  342.         Command:        2;sqrt;1;-
  343. computes sqrt(2)-1 = .414...
  344.  
  345.      STACK: Operands are pushed on a stack,  and  popped  as
  346. they are consumed by commands, which then push their results
  347. on the stack.  In the example above, if the stack was  empty
  348. at  first,  then it would contain only the result .414... at
  349. the end.
  350.  
  351.      When a  new  value  is  pushed  on  the  stack,  it  is
  352. displayed  in decimal and hex floating point format.  If any
  353. IEEE exception flags were raised by the command that created
  354. the  value, then they are displayed.  Abbreviations used are
  355. IV, OV, UN, D0, NO, and NX, for integer  overflow,  floating
  356. point  overflow,  underflow,  divide by zero, invalid opera-
  357. tion, and inexact result.
  358.  
  359.      DATA TYPES: Stack entries  are  kept  in  an  unrounded
  360. extended  format.    The unrounding means that the round and
  361. sticky bits are visible in the hex format.  There  are  com-
  362. mands available to cause stack entries to be kept in single,
  363. double, or rounded extended precision.
  364.  
  365.      HEX FLOATING POINT: Stack entries are displayed in  and
  366.  
  367.  
  368.  
  369.                      September 2, 1985
  370.  
  371.  
  372.  
  373.  
  374.  
  375.                            - 2 -
  376.  
  377.  
  378. may  be  entered in a hex floating point notation, consiting
  379. of hex digits followed by a decimal exponent.  Thus
  380.         1
  381.         1H
  382.         .8h1
  383.         40h-6
  384. are all ways of entering 1.0.  Note that 100h100 means 256.0
  385. * 2**100, NOT 256.0 * 2**256!
  386.  
  387.      TESTING: The command TEST places the  calculator  in  a
  388. mode  for  performing  each computation twice, once with its
  389. built in arithmetic and once with a user-defined  arithmetic
  390. to  be  tested.  For each computational command, results and
  391. exception flags are computed both ways and compared.
  392.  
  393.  
  394.                Setting up the IEEE Calculator
  395.  
  396.      The Calculator is distributed on USENET as a series  of
  397. SHAR  files.   When  run,  these create the necessary source
  398. files in a directory.  One of  these  files  is  a  Makefile
  399. which  can be used to make three versions of the calculator.
  400. The calctest version does NOT test any  user-defined  arith-
  401. metic.   Calc 32 and calc64 test single and double precision
  402. floating point arithmetic in the  Pascal  compiler  pc  con-
  403. tained  in  Release 2.0 of Sun Unix.  These programs operate
  404. the same except when in TEST mode.
  405.  
  406.      Getting the calculator to work in other environments is
  407. primarily a matter of setting up the interface to the arith-
  408. metic to be tested.  This is a system-dependent  matter,  so
  409. have fun.
  410.  
  411.      If it is desired to get the program operational for its
  412. own sake without any intent to test a local IEEE implementa-
  413. tion, modify the Makefile to only create calctest.
  414.  
  415.  
  416.                           Commands
  417.  
  418.      Authoritative information on commands is to be gleaned,
  419. in the best Unix tradition, from detailed examination of the
  420. source code.
  421. TEST    toggle mode to test user-supplied arithmetic
  422. EXIT    quit the program
  423.  
  424. STOX80  change calculator storage mode to rounded extended
  425. STOF64  change calculator storage mode to IEEE double precision
  426. STOF32  change calculator storage mode to IEEE single precision
  427. STOI64  change calculator storage mode to 64 bit 2's complement integer
  428. STOI32  change calculator storage mode to 32 bit 2's complement integer
  429. STOI16  change calculator storage mode to 16 bit 2's complement integer
  430. UNROUNDED change calculator storage mode to unrounded extended (default)
  431.         also change calculator rounding precision mode to 80 significant bits
  432.  
  433.  
  434.  
  435.                      September 2, 1985
  436.  
  437.  
  438.  
  439.  
  440.  
  441.                            - 3 -
  442.  
  443.  
  444. R24     change calculator rounding precision mode to 24 significant bits
  445. R53     change calculator rounding precision mode to 53 significant bits
  446. RN      change calculator rounding mode to round to nearest (default)
  447. RM      change calculator rounding mode to round toward minus infinity
  448. RP      change calculator rounding mode to round toward plus infinity
  449. RZ      change calculator rounding mode to round toward zero
  450. AFF     change calculator infinity mode to affine (default)
  451. PROJ    change calculator infinity mode to projective
  452. NORM    change calculator subnormal mode to normalizing (default)
  453. WARN    change calculator subnormal mode to warning
  454. IV OV UN D0 NO NX
  455.         toggle the trap-enable for the corresponding exception
  456.         default is disabled
  457.  
  458. CLEAR   clear stack
  459. CRUNCH  clear stack except for top two entries
  460. DUP     pop x, then push it twice
  461. DUMP    print out contents of entire stack
  462. POP     pop one operand
  463. REV     pop x and y, push in reverse order
  464. E       push an extended approximation to e
  465. PI      push an extended approximation to pi
  466.  
  467. ABS     pop operand x, push abs(x)
  468. NEG     pop x, push -x
  469. SQRT    pop x, push sqrt(x)
  470. TOF32   pop x, convert to IEEE single precision, push
  471. TOF64   pop x, convert to IEEE double precision, push
  472. TOX80   pop x, convert to rounded extended precision, push
  473. TOF32I  pop x, convert to IEEE single integral value, push
  474. TOF64I  pop x, convert to IEEE double integral value, push
  475. TOX80I  pop x, convert to extended integral value, push
  476. TOI16   pop x, convert to 16 bit 2's complement integer, push
  477. TOI32   pop x, convert to 32 bit 2's complement integer, push
  478. TOI64   pop x, convert to 64 bit 2's complement integer, push
  479.  
  480. +       pop two operands, add, push result
  481. -       pop two operands, sub, push result
  482. *       pop two operands, mul, push result
  483. /       pop two operands, div, push result
  484. COMPARE pop x and y, push numerical result of comparison
  485. DIV     pop x and y, push integral quotient
  486. REM     pop x and y, push IEEE remainder from integral quotient
  487.  
  488. LOGB    an IEEE appendix function, logb
  489. NEXT    an IEEE appendix function, nextafter
  490. SCALE   an IEEE appendix function, scalb
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.                      September 2, 1985
  502.  
  503.  
  504. End-Of-File
  505. echo Extracting Makefile
  506. cat >Makefile <<'End-Of-File'
  507. PASCAL = pc -c -L -w -g
  508. PASCALGO = pc -L -g
  509. OBJSTEST = calc.o calctest.o
  510. OBJS32 = calc.o calcf32.o
  511. OBJS64 = calc.o calcf64.o
  512.  
  513. calc:    calctest calc32 calc64
  514.  
  515. calctest: $(OBJSTEST)
  516.     $(PASCALGO) $(OBJSTEST) $(LIBS) -o calctest
  517.  
  518. calc32: $(OBJS32)
  519.     $(PASCALGO) $(OBJS32) $(LIBS) -o calc32
  520.  
  521. calc64: $(OBJS64)
  522.     $(PASCALGO) $(OBJS64) $(LIBS) -o calc64
  523.  
  524. calctest.o: calctest.p calctest.h sane.h oldfplib.h
  525.     $(PASCAL) calctest.p
  526.  
  527. calcf32.o: calcf32.p calctest.h sane.h oldfplib.h calcsingle.h
  528.     $(PASCAL) calcf32.p
  529.  
  530. calcf64.o: calcf64.p calctest.h sane.h oldfplib.h calcdouble.h
  531.     $(PASCAL) calcf64.p
  532.  
  533. calc.o:    calc.p dotest.i sane.h oldfplib.h calctest.h global.i forward.i init.i divrem.i extra.i storage.i addsubpas.i utility.i function.i hex.i base.i calcdouble.h calcsingle.h
  534.     $(PASCAL) calc.p
  535. End-Of-File
  536. echo ""
  537. echo "End of Kit"
  538. exit
  539.  
  540.