Double
The double type defines a question that requires a numeric response that can contain decimals. The response data is stored using the Double data type, which is a 64-bit floating point number with at least 15 digits of precision, in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
Syntax
For clarity, each item is shown on a separate line, and optional items are indented. See also
Syntax conventions.
field_name [ "field_label" ]
[ [ <properties> ] ]
[ <styles and templates> ]
double [ [ range_expression ] ]
[ precision (integer) ]
[ scale (integer) ]
[ <categories> ]
[ <codes> ]
[ expression ("expression_text") ]
[ ( initialanswer | defaultanswer ) (double_value) ]
[ <axis> ]
[ <usage-type> ]
[ <helperfields> ]
[ nocasedata ]
[ unversioned ]
Parameters
For
<axis>,
<usage-type>,
<helperfields>,
nocasedata, and
unversioned, see
Common parameters.
range_expression
To specify
|
Syntax
|
any real number
|
Field DOUBLE;
Example
Amount double;
Any real number is valid.
|
a range of values
|
Field DOUBLE [ n1 .. n2 ];
|
|
Example:
Temperature double [-40.5..60.9];
|
|
All real numbers between -40.5 and 60.9 inclusive are valid.
|
a minimum to undefined max.
|
Field DOUBLE [ n1 .. ];
|
|
Example:
Traveled double [0..];
|
|
All real numbers greater than or equal to 0 are valid.
|
from undefined min. to max.
|
Field DOUBLE [ .. n1 ];
|
|
Example:
Angle1 double [..45.0];
|
|
All real numbers less than or equal to 45.0 are valid.
|
single values
(Not supported in Data Model 2.8.)
|
Field DOUBLE [ n1 , n2 , n3 , n4 ...];
|
|
Example:
Diameter double [10.5, 72.3, 81.6];
|
|
Values 10.5, 72.3, and 81.6 are valid.
|
several different ranges
|
Field DOUBLE [ n1 .. n2 , n3 .. n4 , n5 .. n6 ...];
|
|
Example:
Rate2 double [24.5..56.7, 100.0..1000.0];
|
|
All real numbers between 24.5 and 56.7 inclusive and between 100 and 1000 inclusive are valid.
|
exclusive values
|
Field DOUBLE [^ n1 .. n2 ];
|
|
Example:
Distance double [-45.6..45.6, ^-1..1];
|
|
All real numbers between -45.6 and 45.6 inclusive, except the real numbers between -1 and 1 inclusive. (In other words, -45.6 to -1 and 1 to 45.6.)
|
precision
An optional precision value can be used to validate an answer against the defined precision value. When the answer exceeds the defined precision value, an error message indicating that the answer contains too many digits is generated.
Precision is typically used in conjunction with scale.
scale
An optional scale value can be used to validate an answer against a defined scale value. When the answer exceeds the defined scale value, an error message indicating that the answer contains too many decimal places is generated.
Fee double [0.00 .. 1000.00] scale(2);
<categories>
You can use the optional categories list to specify that the question will be presented as a single-response categorical question. If a category is selected, the value of the response will be the factor value assigned to that category by the factor keyword. Therefore, all categories should be assigned a factor value, which must always be specified using a dot (.) for the decimal symbol, regardless of the regional settings on your computer. In the following example, the value of InterestRate will be 2.5, 7.5, or 12.5, depending on which of the three categories is selected:
InterestRate "What interest rate are you paying?" double
{
low "0 to 5 percent" factor(2.5),
medium "5 to 10 percent" factor(7.5),
high "10 to 15 percent" factor(12.5)
}
scale(1);
For further information about defining a category list, see
Categorical.
<codes>
The optional codes list is used to define special responses for the question. A code list is defined in the same way as a category list and is typically used to include Don't Know, No Answer, or Refused to Answer responses, which are identified by the DK, NA and REF keywords respectively. For example, the following numeric question called Angle has a Don't Know response. Special responses are automatically marked as exclusive, meaning that they cannot be combined with any other answers. Only decimal numbers 0 to 90, or Don't Know are acceptable responses to this question:
Angle "Angle from 0.0 to 90.0 degrees" double [0 .. 90] codes ( {
Dontknow "Don't know" DK exclusive
} );
When using the DK, REF or NA keywords, you can use a hyphen (-) as the category name to specify that the category name should be the same as the keyword.
expression
The optional expression keyword is used to create a variable using a formula defined in expression_text. Generally you use this feature to create a derived variable that is based on one or more other variables. For example, the following creates a variable that is based on an arithmetic expression that includes the MonthlyIncome double variable.
AnnualIncome "Annual income" double expression ("MonthlyIncome * 12");
expression_text must be an expression that is supported by the UNICOM Intelligence Data Model and can optionally include functions from the
UNICOM Intelligence Function Library. Double quotation marks (") must be escaped using a second double quotation mark (for example,
""yyyy""). Check your syntax and spelling carefully, because the expression is stored without being validated. For more information, see
Expression evaluation.
initialanswer and defaultanswer
You can optionally specify either an initial answer or a default answer to the question. An initial answer can be seen by the respondent, whereas a default answer can not be seen. If either type of answer is defined, the respondent does not need to answer the question. For example:
Price "Average price paid" double [0.00 .. 50.00]
defaultanswer(25.00);
If a default answer is not accepted when you run your interview script (that is, “Missing Answer(s)” is displayed), see
mrScriptMetadata FAQs.
Remarks
For more information about writing Double questions in interview scripts, see
Questions with decimal responses.
Example
This example defines a numeric question called Cost with the text “Approximately how much did you pay?”, for which any positive value between 0 and 100.00 or “Refused to Answer” are valid responses. The value is stored with 2 decimal places:
Cost "Approximately how much did you pay?" double [0 .. 100.00] scale(2)
codes (
{
- "I'd rather not say" REF
} );
See