| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qjsnumbercoercion.h" |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | /*! |
| 9 | \since 6.1 |
| 10 | \class QJSNumberCoercion |
| 11 | \internal |
| 12 | |
| 13 | \brief Implements the JavaScript double-to-int coercion. |
| 14 | */ |
| 15 | |
| 16 | /*! |
| 17 | \fn bool QJSNumberCoercion::isInteger(double d) |
| 18 | \internal |
| 19 | \deprecated 6.7 |
| 20 | */ |
| 21 | |
| 22 | /*! |
| 23 | \fn bool QJSNumberCoercion::isArrayIndex(double d) |
| 24 | \internal |
| 25 | |
| 26 | Checks whether \a d contains a value that can serve as an index into an array. |
| 27 | For that, \a d must be a non-negative value representable as an unsigned 32bit int. |
| 28 | */ |
| 29 | |
| 30 | /*! |
| 31 | \fn bool QJSNumberCoercion::isArrayIndex(qint64 i) |
| 32 | \internal |
| 33 | |
| 34 | Checks whether \a i contains a value that can serve as an index into an array. |
| 35 | For that, \a d must be a non-negative value representable as an unsigned 32bit int. |
| 36 | */ |
| 37 | |
| 38 | /*! |
| 39 | \fn bool QJSNumberCoercion::isArrayIndex(quint64 i) |
| 40 | \internal |
| 41 | |
| 42 | Checks whether \a i contains a value that can serve as an index into an array. |
| 43 | For that, \a d must be a value representable as an unsigned 32bit int. |
| 44 | */ |
| 45 | |
| 46 | /*! |
| 47 | \fn int QJSNumberCoercion::toInteger(double d) |
| 48 | \internal |
| 49 | |
| 50 | Coerces the given \a d to a 32bit integer by JavaScript rules and returns |
| 51 | the result. |
| 52 | */ |
| 53 | |
| 54 | /*! |
| 55 | \fn bool equals(double lhs, double rhs) |
| 56 | \internal |
| 57 | |
| 58 | Compares \a lhs and \a rhs bit by bit without causing a compile warning. |
| 59 | Returns the \c true if they are equal, or \c false if not. |
| 60 | */ |
| 61 | |
| 62 | /*! |
| 63 | \fn double QJSNumberCoercion::roundTowards0(double d) |
| 64 | \internal |
| 65 | |
| 66 | Rounds \a d towards 0 by JavaScript \e ToInteger rules and returns the result. |
| 67 | */ |
| 68 | |
| 69 | QT_END_NAMESPACE |
| 70 | |