Variant
toDouble() [Variant class]
Returns the value of the variant to an double (8 byte or 64-bit double precision floating point), converting the type if necessary. The original value is left unchanged.
| Source | Result |
|---|---|
| bool | false → 0.0, true → 1.0 |
| numeric | unchanged |
| String | string number → double floating point |
| other | conversion fails |
If the value of the double it within the bounds of a float you can static cast from double to float. A float (single precision, 4-byte or 32-bit) will be promoted to a double automatically if necessary.
There are two overloads, one that takes an ok parameter passed by reference, which is filled in as
true if the data is already this type or can be converted.
// PROTOTYPES
double toDouble() const;
double toDouble(bool& ok) const;
See value, as, and to for when to use the toXXX() vs. other accessors.