Cumulative standard deviation: Difference between revisions
Content added Content deleted
(Delphi: see Pascal.) |
m (→{{header|REXX}}: changed extra digits and optimized the sqrt function, added a comment.) |
||
Line 2,770: | Line 2,770: | ||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*────────────────────────────────────────────────────────────────────────────*/ |
/*────────────────────────────────────────────────────────────────────────────*/ |
||
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); |
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); i=; m.=9 |
||
numeric digits 9; numeric form; |
numeric digits 9; numeric form; h=d+6; if x<0 then do; x=-x; i='i'; end |
||
parse value format(x,2,1,,0) 'E0' with g 'E' _ .; g=g*.5'e'_%2 |
|||
do j=0 while h>9; m.j=h; h=h%2+1; end /*j*/ |
|||
numeric digits |
do k=j+5 to 0 by -1; numeric digits m.k; g=(g+x/g)*.5; end /*k*/ |
||
numeric digits d; return (g/1)i /*make complex if X < 0.*/</lang> |
|||
'''output''' when using the default input of: <tt> 2 4 4 4 5 5 7 9 </tt> |
'''output''' when using the default input of: <tt> 2 4 4 4 5 5 7 9 </tt> |
||
<pre> |
<pre> |