-
Notifications
You must be signed in to change notification settings - Fork 6
COM Data Types in Scriptom
The following table summarizes the equivalent types between Scriptom and COM (VB6/VBA/.NET).
Groovy/Java | VB6/VBA | VB.NET | Comments |
---|---|---|---|
null | Null | ??? | VariantNull is not the same as Java null. Use Scriptom.NULL. |
VariantNull | Boolean | Boolean | |
byte | byte | Byte/SByte | 8-bit signed or unsigned integer. 0 to 255 in the COM library. -128 to 127 in Java. Conversion happens automatically. |
short | Integer | Short | 16-bit signed integer. -32,768 to 32,767. |
int | Long | Integer | 32-bit signed integer. -2,147,483,648 to 2,147,483,647. |
(long) | - | UInteger | 32-bit unsigned integer. 0 to 4,294,967,295. |
long | - | Long | 64-bit signed integer. -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. 64-bit integers are not supported by COM in Windows Millenium or Windows 2000 and earlier. |
(BigInteger) | - | ULong | 64-bit unsigned integer. 0 to 18,446,744,073,709,551,615. 64-bit integers are not supported by COM in Windows Millenium or Windows 2000 and earlier. |
float | Single | Single | Low-precision floating point. -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values. |
double | Double | Double | High-precision floating point. The range of a Double is -1.79769313486231E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. |
BigDecimal | - | Decimal | High-precision fixed/floating point (96 bits plus scaling), but without the large mantissa values supported by Double. Scriptom supports the Currency data type by converting to and from Decimal. The range of a Decimal is +/-79,228,162,514,264,337,593,543,950,335 for zero-scaled numbers (that is, numbers with no decimal places). For numbers with 28 decimal places, the range is +/-7.9228162514264337593543950335. The smallest possible non-zero number is 0.0000000000000000000000000001. BigDecimal values with greater precision than Decimal supports are automatically rounded. |
BigDecimal | Currency | - | Numbers from -922,337,203,685,477.5808 to 922,337,203,685,477.5807, with a fixed decimal point. Scriptom handles Currency values internally as type Decimal. |
Date | Date | Date | |
String | String | String | |
SafeArray | Array | Array | |
ActiveXObject | A COM-callable object | A COM-callable object |
Note that implicit type conversions are supported, so you could - for instance - pass a float to a method that expects a double. COM unsigned integer types are converted to the next largest Java signed equivalent integer type so that large positive values do not cause overflows.
CAUTION: The default floating-point type in Groovy is BigDecimal, which gets converted to a COM Decimal. Although Decimal will work in the majority of cases, type conversions involving Decimal are inefficient compared to other numeric types. It is a good idea to explicitly coerce Decimal values to type Double or type Integer, whichever makes the most sense. Also note that Decimal does not handle the types of large mantissas that type Double can, but it supports more precision.