MOF Numeric Data Types

[This is preliminary documentation and subject to change.]

MOF supports the following types of numeric values:

Data type Automation type Description
Sint8 VT_I2 Signed 8-bit integer
Sint16 VT_I2 Signed 16-bit integer
Sint32 VT_I4 Signed 32-bit integer
Sint64 VT_BSTR Signed 64-bit integer in string form. Hexadecimal or decimal format according to ANSI C rules.
Real32 VT_R4 IEEE 4-byte floating-point
Real64 VT_R8 IEEE 8-byte floating-point
Uint8 VT_UI1 Unsigned 8-bit integer
Uint16 VT_I4 Unsigned 16-bit integer
Uint32 VT_I4 Unsigned 32-bit integer
Uint64 VT_BSTR Unsigned 64-bit integer in string form. Hexadecimal or decimal format according to ANSI C rules.

Note  64-bit integers must be encoded as string because Automation does not support a 64-bit integral type.

Automation types do not always correspond in bit size to MOF data types. For example, VT_I4 is used to return an Uint16 value. This is because of sign extension problems. If VT_I2 was used instead of VT_I4, 65,536 would appear to be the value -1, causing a number of type and range problems.

Since Automation does support an unsigned 8 bit type, VT_UI1, no change in representation is required. The Uint32 type is represented as VT_I4 because there is no larger integer type to contain it.

Long constants are integer values that are declared using a simple series of digits with an optional negative sign. The long constant may not exceed the size of the variable that is declared to hold it. Some examples of long constants are 1000 and -12310.

Hexadecimal, binary, and octal constants are also supported:

val = 65;                        // Decimal
val = 0x41;                    // Hex (0x prefix)
val = 0101;                    // Octal (leading zero)
val = 1000001B;                // Binary (trailing B)

Binary constants have a series of 1 and 0 digits, with a "b" or "B" suffix to indicate that the value is binary.

Floating point constants can be used to represent scientific notation as well as fractions:

3.14
-3.14
-1.2778E+02

The following class and instance declarations illustrate how to use each of the numeric data types to set properties:

class NumericDataClass
{
    uint8            Duint8;
    SInt8            Dchar;
    UInt16               Dtword;
    Sint16               Dinst16;
    UInt32               DDword;
    Sint32               Dinst1;
    Sint32               Dinst2;
    Sint32               Dinst3;
    Sint32               Dinst4;
    Sint32               Dinst5;
    Real32           Dfloat;
    Real64               Ddouble1;
    Real64               Ddouble2;
}

instance of NumericDataClass
{
    Duint8   =  122;
    Dchar    = -128;
    Dtword   =  30;
    Dinst16  = -1445;
    Ddword   =  6987777;
    Dinst1   = -455589;
    Dinst2   =  23;
    Dinst3   =  03;                // base 8
    Dinst4   =  0xFe;                // base 16
    Dinst5   =  11b;                // base 2
    Dfloat   =  3.1478;
    Ddouble1 =  99987.3654;
    Ddouble2 =  2.3e-2;
}