Tuesday, July 18, 2006

Controlling Precision and Presentation - DECIMAL, DIGIT and FORMAT

Dicom calculation result can be formatted using DECIMAL, DIGIT, and FORMAT command.

  • DECIMAL is used to set number of digits after decimal point, large value is displayed in normal notation
  • DIGIT is used to set number of significant digits, large value is displayed using exponential notation
  • FORMAT is used to format the result

Syntax of DECIMAL Command

[SET] DECIMAL []


n can be any value between 0 and 18. If it is not specified or 0 the decimal is reset to default 15.

Example:

DECIMAL; 2.34^15 = 345332.824799534
DECIAML 2; 2.34^15 = 345332.82

Syntax of DIGIT Command

[SET] DIGIT []


n can be any value between 0 and 18. If it is not specified or 0 the decimal is reset to default 15.

Example:

DIGIT; 2.34^15 = 345332.824799534
DIGIT 2; 2.34^15 =3.5e+005

You may notice that DIGIT or DECIMAL without any value specified defaults to same format, which is 15 significant digits with exponential form for large value.

Syntax of FORMAT Command

[SET] FORMAT ['']


spec is the format specifier enclosed within single quotes ( ' )
The spec follows the C/C++ format convention. Some examples are shown below:

Example:

FORMAT '%x' ; 255 = ff (hexadecimal)
FORMAT '%i' ; 13/3 = 4 (signed integer)
FORMAT '%f' ; 13/3 = 4.333333 (6 decimal float)
FORMAT '%.15g' ; 13/3 = 4.33333333333333 (dicom default i.e. 15 decimal float, may use exponential notation when required)

Clik here to visit Knowbotron's web site.