Generalised floating point addition: Difference between revisions

m
→‎{{header|REXX}}: added code to show the length of the BCD number, also showed more output. -- ~~~~
(moved REXX to its proper place alphabetically. -- ~~~~)
m (→‎{{header|REXX}}: added code to show the length of the BCD number, also showed more output. -- ~~~~)
Line 604:
 
maxW=200-1 /*max width allowed for displays.*/
/*ideally: maxW=linesize()-1 */
_123=012345679; reps=0; mult=63 /*used to construct test cases. */
say ' # addend uncompressed (zoned) BCD number' /*header.*/
Line 614 ⟶ 615:
parse var BCD.j '^' pow /*get the exponent part of the #.*/
addend.j='1e'pow /*build the addend the hard way. */
aLine_=right(j,2) right(addend.j,6) BCD.j /*construct athe lineprefix offor outputa line*/
aLine=_ BCD.j /*construct a line of output. */
if length(aLine)<maxW then say aLine /*Fit on a line? Display it*/
else say _ ' ['length(BCD.j) 'digits]' /*other*/
mult=mult-9 /*decrease multiplier's exponent.*/
maxDigs=length(BCD.j)+abs(pow)+5 /*compute max precision needed. */
Line 659 ⟶ 662:
11 1e-99 12345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679^-99
12 1e-108 +12345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679012345679^-108
13 1e-117 [193 digits]
14 1e-126 [202 digits]
15 1e-135 [212 digits]
16 1e-144 [220 digits]
17 1e-153 [229 digits]
18 1e-162 [239 digits]
19 1e-171 [247 digits]
20 1e-180 [256 digits]
21 1e-189 [266 digits]
═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
-7 sum=1E+72