1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /*global intl_NumberFormat: false, */
8 var numberFormatCache = new Record();
12 * Format this Number object into a string, using the locale and formatting options
15 * Spec: ECMAScript Language Specification, 5.1 edition, 15.7.4.3.
16 * Spec: ECMAScript Internationalization API Specification, 13.2.1.
18 function Number_toLocaleString() {
19 // Steps 1-2. Note that valueOf enforces "this Number value" restrictions.
20 var x = callFunction(std_Number_valueOf, this);
23 var locales = arguments.length > 0 ? arguments[0] : undefined;
24 var options = arguments.length > 1 ? arguments[1] : undefined;
28 if (locales === undefined && options === undefined) {
29 // This cache only optimizes for the old ES5 toLocaleString without
30 // locales and options.
31 if (numberFormatCache.numberFormat === undefined)
32 numberFormatCache.numberFormat = intl_NumberFormat(locales, options);
33 numberFormat = numberFormatCache.numberFormat;
35 numberFormat = intl_NumberFormat(locales, options);
39 return intl_FormatNumber(numberFormat, x);
42 // ES6 draft ES6 20.1.2.4
43 function Number_isFinite(num) {
44 if (typeof num !== "number")
46 return num - num === 0;
49 // ES6 draft ES6 20.1.2.2
50 function Number_isNaN(num) {
51 if (typeof num !== "number")
56 // ES6 draft ES6 20.1.2.5
57 function Number_isSafeInteger(number) {
59 if (typeof number !== 'number')
63 if (!Number_isFinite(number))
67 var integer = ToInteger(number);
70 if (integer !== number)
73 // Step 5. If abs(integer) <= 2**53 - 1, return true.
74 if (std_Math_abs(integer) <= 9007199254740991)
81 function Global_isNaN(number) {
82 return Number_isNaN(ToNumber(number));
85 function Global_isFinite(number){
86 return Number_isFinite(ToNumber(number));