A Decimal is a high-precision signed decimal number. It consists of an arbitrary precision integer unscaled value and an integer scale. The scale is the power of ten that is applied to the unscaled value.
A Decimal has the fields described in Table 3.
Table 3 – Layout of Decimal
|TypeId||NodeId||The identifier for the Decimal DataType.|
|Encoding||Byte||This value is always 1.|
|Length||Int32||The length of the Scale and Value fields in bytes. If the length is less than or equal to 2 then the Decimal is an invalid value that cannot be used.|
|Scale||Int16||A signed integer representing scale which is the inverse power of ten that is applied to the unscaled value. i.e., the decimal number of the value multiplied by 10-scaleThe integer is encoded starting with the least significant bit.|
|Value||OctetString||A 2-complement signed integer representing the unscaled value. The number of bytes is the value of the Length field minus size of the Scale field.The integer is encoded with the least significant byte first.|
When a Decimal is encoded in a Variant the built-in type is set to ExtensionObject. Decoders that do not understand the Decimal type shall treat it like any other unknown Structure and pass it on to the application. Decoders that do understand the Decimal can parse the value and use any construct that is suitable for the DevelopmentPlatform. Note that a Decimal is like a built-in type and a DevelopmentPlatform has to have hardcoded knowledge of the type. No Structure metadata is published for this type.
If a Decimal is embedded in another Structure then the DataTypeDefinition for the field shall specify the NodeId of the Decimal Node as the DataType. If a Server publishes an OPC Binary type description for the Structure then the type description shall set the DataType for the field to ExtensionObject.