Pathological floating point problems: Difference between revisions

m
m (→‎{{header|REXX}}: used a template for the output sections.)
m (→‎A sequence that seems to converge to a wrong limit: changed a comment and whitespace.)
Line 2,208:
<br>calculations, &nbsp; as well how many decimal digits &nbsp; (past the decimal point) &nbsp; should be displayed.
===A sequence that seems to converge to a wrong limit===
<lang rexx>/*REXX pgm (pathological FP problem): a sequence that seems tomight converge to a wrong limit. */
parse arg digs show . /*obtain optional arguments from the CL*/
if digs=='' | digs=="," then digs=150 150 /*Not specified? Then use the default.*/
if show=='' | show=="," then show= 20 20 /* " " " " " " */
numeric digits digs /*have REXX use "digs" decimal digits. */
#= 2 4 5 6 7 8 9 20 30 50 100 /*the indices to display value of V.n */
fin= word(#, words(#) ) /*find the last (largest) index number.*/
w= length(fin) /* " " length (in dec digs) of FIN.*/
v.1= 2 /*the value of the first V element. */
v.2=-4 /* " " " " second " " */
do n=3 to fin; nm1= n-1; nm2= n-2 /*compute some values of the V elements*/
v.n= 111 - 1130/v.nm1 + 3000/(v.nm1*v.nm2) /* " a value of a " element.*/
if wordpos(n, #)\==0 then say 'v.'left(n, w) "=" format(v.n, , show)
end /*n*/ /*display SHOW digs past the dec. pointpoint───┘ */
/*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the default inputs:}}