Formatting Floating-Point Output Parameters
Floating-point numbers used as output parameters in method and property responses can be formatted in a variety of ways. Scalar floating-point parameters are read from the instrument as ASCII text and converted to numeric values. Floating-point arrays can be read from the instrument in the following formats:
- An ASCII list of values separated by commas or another specified delimiter.
- An IEEE 488.2 binary block.
This topic presents the format specifications for reading data from the device as ASCII text. For detailed information on reading array data as IEEE binary blocks, see the topic Reading and Writing IEEE 488.2 Binary Block Data.
Floating-point numbers used as output parameters have format specifications of the following general form:
%[488.2 type] [.precision] [delimiter] [f | e | E | g | G]
| Modifier | Interpretation |
|---|---|
488.2 type | The number is expected to be in one of six standard IEEE 488.2 numeric formats. The supported formats are: @1 - IEEE 488.2 NR1 format (integer without any decimal point). Example: 123@2 - IEEE 488.2 NR2 format (number with at least one digit after the decimal point). Example: 123.45@3 - IEEE 488.2 NR3 format (floating-point number in exponential form). Example: 1.2345E-67@H - IEEE 488.2 hex format. Example: #HAF35B@Q - IEEE 488.2 octal format. Example: #Q71234@B - IEEE 488.2 binary format. Example: #B011101001 |
delimiter | The parameter must be an array of floating-point numbers. The elements of the array are sent to the device with the specified delimiter between each element. The following delimiters are supported. Note that the enclosing parentheses are not required for comma-separated lists: , or (,) - comma-separated list(;) - semicolon-separated list(:) - colon-separated list(s) - space-separated list(t) - tab-separated list(r) - carriage return-separated list(n) - linefeed-separated list |
type | f - signed value having the form dddd.ddddwhere dddd is one or more digits.The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision. Example: 3.1415e - signed value having the form d.dddd e [+ \| -]dddwhere d is a single digit, dddd is one or more digits, ddd is exactly three digits.Example: 3.14e-123E - identical to e format except that E rather than e introduces the exponent.Example: 3.14E-123g - signed value in f or e format, whichever is more compact for the given value and precision.The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision.Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it. G - Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).. |
Examples: Output Floating-Point Parameter
Section titled “Examples: Output Floating-Point Parameter”| Parameter Tag | Data Expected from Device |
|---|---|
| {Frequency:%e} | Data from device: 1.53E-12 Data copied to output parameter: 1.5E-12 |
| {FrequencyArray:%,e} | Data from device: 1.23,4.0E-56,0.789 Data copied to output parameter: FrequencyArray[0]: 1.23 FrequencyArray[1]: 4.0E-56 FrequencyArray[2]: 0.789 |
| {FrequencyArray:%@H(:)g} | Data from device: #HA7B:#H12:#H4FDD Data copied to output parameter: FrequencyArray[0]: 2683 FrequencyArray[1]: 18 FrequencyArray[2]: 20445 |