Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / doc / src / declarative / qmlnumber.qdoc
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the documentation of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:FDL$
9 ** GNU Free Documentation License
10 ** Alternatively, this file may be used under the terms of the GNU Free
11 ** Documentation License version 1.3 as published by the Free Software
12 ** Foundation and appearing in the file included in the packaging of
13 ** this file.
14 **
15 ** Other Usage
16 ** Alternatively, this file may be used in accordance with the terms
17 ** and conditions contained in a signed written agreement between you
18 ** and Nokia.
19 **
20 **
21 **
22 **
23 **
24 ** $QT_END_LICENSE$
25 **
26 ****************************************************************************/
27
28 /*!
29     \qmlclass Number
30     \inqmlmodule QtQuick 2
31     \brief The Number object provides represents a number value
32
33     The QML Number object extends the JS Number object with
34     locale aware functions.
35
36     \sa {QtQuick2::Locale}{Locale}
37 */
38
39 /*!
40     \qmlmethod string Number::toLocaleString(locale,format,precision)
41
42     Converts the Number to a string suitable for the specified \a locale
43     in the specified \a format, with the specified \a precision.
44
45     Valid formats are:
46     \list
47     \o 'f'   Decimal floating point, e.g. 248.65
48     \o 'e'   Scientific notation using e character, e.g. 2.4865e+2
49     \o 'E'   Scientific notation using E character, e.g. 2.4865E+2
50     \o 'g'   Use the shorter of e or f
51     \o 'G'   Use the shorter of E or f
52     \endlist
53
54     If precision is not specified, the precision will be 2.
55
56     If the format is not specified 'f' will be used.
57
58     If \a locale is not specified, the default locale will be used.
59
60     The following example shows a number formatted for the German locale:
61     \code
62     import QtQuick 2.0
63
64     Text {
65         text: "The value is: " +  Number(4742378.423).toLocaleString(Qt.locale("de_DE"))
66     }
67     \endcode
68
69     You can apply toLocaleString() directly to constants, provided the decimal
70     is included in the constant, e.g.
71     \code
72     123.0.toLocaleString(Qt.locale("de_DE")) // OK
73     123..toLocaleString(Qt.locale("de_DE"))  // OK
74     123.toLocaleString(Qt.locale("de_DE"))   // fails
75     \endcode
76 */
77
78 /*!
79     \qmlmethod string Number::toLocaleCurrencyString(locale,symbol)
80
81     Converts the Number to a currency using the currency and conventions of the specified
82     \a locale.  If \a symbol is specified it will be used as the currency
83     symbol.
84
85     \sa Locale::currencySymbol()
86 */
87
88 /*!
89     \qmlmethod string Number::fromLocaleString(locale,number)
90
91     Returns a Number by parsing \a number using the conventions of the supplied \a locale.
92
93     If \a locale is not supplied the default locale will be used.
94
95     For example, using the German locale:
96     \code
97     var german = Qt.locale("de_DE");
98     var d;
99     d = Number.fromLocaleString(german, "1234,56)   // d == 1234.56
100     d = Number.fromLocaleString(german, "1.234,56") // d == 1234.56
101     d = Number.fromLocaleString(german, "1234.56")  // throws exception
102     d = Number.fromLocaleString(german, "1.234")    // d == 1234.0
103     \endcode
104 */
105