1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15declare function print(arg:any):string; 16{ 17 // test new builtin array 18 let numObj1 = "-100"; 19 print(Number.parseInt(numObj1)); 20 21 let numObj2 = "1000"; 22 print(Number.parseInt(numObj2)); 23 24 let numObj3 = "0001030"; 25 print(Number.parseInt(numObj3)); 26 27 let numObj4 = " -1123"; 28 print(Number.parseInt(numObj4)); 29} 30print() 31 32//isNaN 33print(Number.isNaN(NaN)); // true 34print(Number.isNaN(123)); // false 35print(Number.isNaN("Hello")); // false 36print(Number.isNaN(undefined)); // false 37print(Number.isNaN(null)); // false 38print(Number.isNaN({})); // false 39print() 40 41//isFinite 42print(Number.isFinite(0)); // true 43print(Number.isFinite(3.14)); // true 44print(Number.isFinite(Infinity)); // false 45print(Number.isFinite(-Infinity)); // false 46print(Number.isFinite(NaN)); // false 47print() 48 49//isInteger 50print(Number.isInteger(0)); // true 51print(Number.isInteger(3.14)); // false 52print(Number.isInteger(123456789012345)); // true 53print(Number.isInteger(Infinity)); // false 54print() 55 56//isSafeIntger 57print(Number.isSafeInteger(0)); // true 58print(Number.isSafeInteger(123456789012345)); // false 59print(Number.isSafeInteger(9007199254740991)); // true 60print(Number.isSafeInteger(-9007199254740991)); // true