Averages/Arithmetic mean: Difference between revisions
Content added Content deleted
PatGarrett (talk | contribs) (→{{header|360 Assembly}}: Section added) |
|||
Line 2: | Line 2: | ||
See also: [[Median]], [[Mode]] |
See also: [[Median]], [[Mode]] |
||
=={{header|360 Assembly}}== |
|||
Compact and functional. |
|||
<lang 360asm> |
|||
AVGP CSECT |
|||
USING AVGP,12 |
|||
LR 12,15 |
|||
SR 3,3 i=0 |
|||
SR 6,6 sum=0 |
|||
LOOP CH 3,=AL2(NN-T-1) for i=1 to nn |
|||
BH ENDLOOP |
|||
L 2,T(3) t(i) |
|||
MH 2,=H'100' scaling factor=2 |
|||
AR 6,2 sum=sum+t(i) |
|||
LA 3,4(3) next i |
|||
B LOOP |
|||
ENDLOOP LR 5,6 sum |
|||
LA 4,0 |
|||
D 4,NN sum/nn |
|||
XDECO 5,Z edit binary |
|||
MVC U,Z+10 descale |
|||
MVI Z+10,C'.' |
|||
MVC Z+11(2),U |
|||
XPRNT Z,80 output |
|||
XR 15,15 |
|||
BR 14 |
|||
T DC F'10',F'9',F'8',F'7',F'6',F'5',F'4',F'3',F'2',F'1' |
|||
NN DC A((NN-T)/4) |
|||
Z DC CL80' ' |
|||
U DS CL2 |
|||
END AVGP |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
5.50 |
|||
</pre> |
|||
=={{header|6502 Assembly}}== |
=={{header|6502 Assembly}}== |
||
Line 46: | Line 83: | ||
PLA |
PLA |
||
RTS ;return from routine</lang> |
RTS ;return from routine</lang> |
||
=={{header|8th}}== |
=={{header|8th}}== |
||
<lang forth> |
<lang forth> |