Get the value as double type. ! \note If the value is 64-bit integer type, it may lose precision. Use \c IsLosslessDouble() to check whether the converison is lossless. */
| 1693 | /*! \note If the value is 64-bit integer type, it may lose precision. Use \c IsLosslessDouble() to check whether the converison is lossless. |
| 1694 | */ |
| 1695 | double GetDouble() const { |
| 1696 | RAPIDJSON_ASSERT(IsNumber()); |
| 1697 | if ((data_.f.flags & kDoubleFlag) != 0) return data_.n.d; // exact type, no conversion. |
| 1698 | if ((data_.f.flags & kIntFlag) != 0) return data_.n.i.i; // int -> double |
| 1699 | if ((data_.f.flags & kUintFlag) != 0) return data_.n.u.u; // unsigned -> double |
| 1700 | if ((data_.f.flags & kInt64Flag) != 0) return static_cast<double>(data_.n.i64); // int64_t -> double (may lose precision) |
| 1701 | RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0); return static_cast<double>(data_.n.u64); // uint64_t -> double (may lose precision) |
| 1702 | } |
| 1703 | |
| 1704 | //! Get the value as float type. |
| 1705 | /*! \note If the value is 64-bit integer type, it may lose precision. Use \c IsLosslessFloat() to check whether the converison is lossless. |
no test coverage detected