1/* 2 * Copyright (c) 2021-2024 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 */ 15 16package std.core; 17 18/** 19 * Can be implemented by any type that represents a numeric value. 20 */ 21export abstract class Numeric extends Object { 22 23 /** 24 * Returns the value of an object as a byte 25 * 26 * @returns object's value 27 */ 28 public abstract byteValue(): byte; 29 30 /** 31 * Returns the value of an object as an int 32 * 33 * @returns object's value 34 */ 35 public abstract intValue(): int; 36 37 /** 38 * Returns the value of an object as a short 39 * 40 * @returns object's value 41 */ 42 public abstract shortValue(): short; 43 44 /** 45 * Returns the value of an object as a long 46 * 47 * @returns object's value 48 */ 49 public abstract longValue(): long; 50 51 /** 52 * Returns the value of an object as a float 53 * 54 * @returns object's value 55 */ 56 public abstract floatValue(): float; 57 58 /** 59 * Returns the value of an object as a double 60 * 61 * @returns object's value 62 */ 63 public abstract doubleValue(): double; 64} 65 66/** 67 * Common class for all integral types 68 */ 69export abstract class Integral extends Numeric {} 70 71/** 72 * Common class for all real number 73 */ 74export abstract class Floating extends Numeric {} 75