1. List average AVE/AVED/AVEF
1. List average AVE/AVED/AVEF
1.1. Instruction description
The Average Value of Single word List (AVE) instruction calculates the average value of all values in the list and outputs it to RES. The Average Value of Double Character List (AVED) calculates double characters, while the Average Value of Floating Point List (AVEF) calculates floating points.
Calculate the average of integers, and then round down the final value
For example, AVE D10 D0 K5 calculates the average of all values from D10 to D14 and stores it in D0.
图1 List average
1.2. The valid operands of the instruction
1.2.1. Average Value of Single word List(AVE)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| T | 16 bit integer | D | List |
| RES | 16 bit integer | D/CV/TV/AO/V/Z, bit composite word (Y/M/C/T/S), local variable (LW) | result |
| N | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | length |
1.2.2. Average Value of Double Word List(AVED)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| T | 32-bit integer | D | List |
| RES | 32-bit integer | D/CV, bit composite word (Y/M/C/T/S), local variable (LD) | result |
| N | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | length |
1.2.3. Floating List Average(AVEF)
| T | 32-bit Real Number | D | List |
| RES | 32-bit real number | D, local variable (LF) | result |
| N | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | length |
1.3. Example
command table:
NETWORK 000
LDP X000
AVE D10 D0 K5 // Calculate the value of (D10+D11+D12+D13+D14)/5 and store it in D0.
图2 AVE