# A numeric value supporting mathematical operations

### Introduced properties

##### abstract fun *(i: OTHER): OTHER

core :: Numeric :: *

Multiplication of `self` with `i`
##### abstract fun +(i: OTHER): OTHER

core :: Numeric :: +

Addition of `self` with `i`
##### abstract fun -(i: OTHER): OTHER

core :: Numeric :: -

Substraction of `i` from `self`
##### abstract fun /(i: OTHER): OTHER

core :: Numeric :: /

Division of `self` with `i`
##### abstract fun add(other: Numeric): Numeric

Universal `+` with any `Numeric`
##### init defaultinit

core :: Numeric :: defaultinit

##### abstract fun div(other: Numeric): Numeric

core :: Numeric :: div

Universal `/` with any `Numeric`
##### fun is_zero: Bool

core :: Numeric :: is_zero

Is this the value of zero in its domain?
##### abstract fun mul(other: Numeric): Numeric

core :: Numeric :: mul

Universal `*` with any `Numeric`
##### abstract fun sub(other: Numeric): Numeric

core :: Numeric :: sub

Universal `-` with any `Numeric`
##### abstract fun to_b: Byte

core :: Numeric :: to_b

The byte equivalent of `self`
##### fun to_bi: BigInt

core :: Numeric :: to_bi

The BigInt equivalent of `self`
##### abstract fun to_f: Float

core :: Numeric :: to_f

The float equivalent of `self`
##### abstract fun to_i: Int

core :: Numeric :: to_i

The integer part of `self`.
##### fun to_i16: Int16

core :: Numeric :: to_i16

The Int16 equivalent of `self`
##### fun to_i32: Int32

core :: Numeric :: to_i32

The Int32 equivalent of `self`
##### fun to_i8: Int8

core :: Numeric :: to_i8

The Int8 equivalent of `self`
##### fun to_r: Ratio

core :: Numeric :: to_r

The Ratio equivalent of `self`
##### fun to_u16: UInt16

core :: Numeric :: to_u16

The UInt16 equivalent of `self`
##### fun to_u32: UInt32

core :: Numeric :: to_u32

The UInt32 equivalent of `self`
##### abstract fun unary -: OTHER

core :: Numeric :: unary -

Inverse of `self`
##### abstract fun value_of(val: Numeric): OTHER

core :: Numeric :: value_of

The value of `val` in the domain of `self`
##### abstract fun zero: OTHER

core :: Numeric :: zero

The value of zero in the domain of `self`

### Redefined properties

##### redef type OTHER: Numeric

core \$ Numeric :: OTHER

What `self` can be compared to?
##### redef type SELF: Numeric

core \$ Numeric :: SELF

Type of this instance, automatically specialized in every class

## All properties

##### fun !=(other: nullable Object): Bool

core :: Object :: !=

Have `self` and `other` different values?
##### abstract fun *(i: OTHER): OTHER

core :: Numeric :: *

Multiplication of `self` with `i`
##### abstract fun +(i: OTHER): OTHER

core :: Numeric :: +

Addition of `self` with `i`
##### abstract fun -(i: OTHER): OTHER

core :: Numeric :: -

Substraction of `i` from `self`
##### abstract fun /(i: OTHER): OTHER

core :: Numeric :: /

Division of `self` with `i`
##### abstract fun <(other: OTHER): Bool

core :: Comparable :: <

Is `self` lesser than `other`?
##### fun <=(other: OTHER): Bool

core :: Comparable :: <=

not `other` < `self`
##### fun <=>(other: OTHER): Int

core :: Comparable :: <=>

-1 if <, +1 if > and 0 otherwise
##### fun ==(other: nullable Object): Bool

core :: Object :: ==

Have `self` and `other` the same value?
##### fun >(other: OTHER): Bool

core :: Comparable :: >

`other` < `self`
##### fun >=(other: OTHER): Bool

core :: Comparable :: >=

not `self` < `other`
##### type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
##### type OTHER: Comparable

core :: Comparable :: OTHER

What `self` can be compared to?
##### type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
##### abstract fun add(other: Numeric): Numeric

Universal `+` with any `Numeric`
##### fun clamp(min: OTHER, max: OTHER): OTHER

core :: Comparable :: clamp

Constraint `self` within `[min..max]`
##### protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by `get_class` to create the specific class.
##### fun class_name: String

core :: Object :: class_name

The class name of the object.
##### init defaultinit

core :: Comparable :: defaultinit

##### init defaultinit

core :: Numeric :: defaultinit

##### init defaultinit

core :: Object :: defaultinit

##### abstract fun div(other: Numeric): Numeric

core :: Numeric :: div

Universal `/` with any `Numeric`
##### fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of `self`.
##### fun hash: Int

core :: Object :: hash

The hash code of the object.
##### init init

core :: Object :: init

##### fun inspect: String

core :: Object :: inspect

Developer readable representation of `self`.

Return "CLASSNAME:#OBJECTID".
##### fun is_between(c: OTHER, d: OTHER): Bool

core :: Comparable :: is_between

c <= self <= d
##### intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if `self` and `other` are the same instance (i.e. same identity).
##### fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is `self` the same as `other` in a serialization context?
##### intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if `self` and `other` have the same dynamic type.
##### fun is_zero: Bool

core :: Numeric :: is_zero

Is this the value of zero in its domain?
##### fun max(other: OTHER): OTHER

core :: Comparable :: max

The maximum between `self` and `other` (prefers `self` if equals).
##### fun min(c: OTHER): OTHER

core :: Comparable :: min

The minimum between `self` and `c` (prefer `self` if equals)
##### abstract fun mul(other: Numeric): Numeric

core :: Numeric :: mul

Universal `*` with any `Numeric`
##### intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
##### fun output

core :: Object :: output

Display self on stdout (debug only).
##### intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
##### fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
##### abstract fun sub(other: Numeric): Numeric

core :: Numeric :: sub

Universal `-` with any `Numeric`
##### intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the `Sys` class.
##### abstract fun to_b: Byte

core :: Numeric :: to_b

The byte equivalent of `self`
##### fun to_bi: BigInt

core :: Numeric :: to_bi

The BigInt equivalent of `self`
##### abstract fun to_f: Float

core :: Numeric :: to_f

The float equivalent of `self`
##### abstract fun to_i: Int

core :: Numeric :: to_i

The integer part of `self`.
##### fun to_i16: Int16

core :: Numeric :: to_i16

The Int16 equivalent of `self`
##### fun to_i32: Int32

core :: Numeric :: to_i32

The Int32 equivalent of `self`
##### fun to_i8: Int8

core :: Numeric :: to_i8

The Int8 equivalent of `self`
##### abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

##### fun to_r: Ratio

core :: Numeric :: to_r

The Ratio equivalent of `self`
##### fun to_s: String

core :: Object :: to_s

User readable representation of `self`.
##### fun to_u16: UInt16

core :: Numeric :: to_u16

The UInt16 equivalent of `self`
##### fun to_u32: UInt32

core :: Numeric :: to_u32

The UInt32 equivalent of `self`
##### abstract fun unary -: OTHER

core :: Numeric :: unary -

Inverse of `self`
##### abstract fun value_of(val: Numeric): OTHER

core :: Numeric :: value_of

The value of `val` in the domain of `self`
##### abstract fun zero: OTHER

core :: Numeric :: zero

The value of zero in the domain of `self`

### Ancestors

##### interface Object

core :: Object

The root of the class hierarchy.

### Parents

##### interface Comparable

core :: Comparable

The ancestor of class where objects are in a total order.

### Children

##### class BigInt

gmp :: BigInt

Multi precision Integer numbers.

core :: Byte

Native bytes.
##### enum Float

core :: Float

Native floating point numbers.
##### enum Int

core :: Int

Native integer numbers.
##### enum Int16

core :: Int16

Native 16-bit signed integer.
##### enum Int32

core :: Int32

Native 32-bit signed integer.
##### enum Int8

core :: Int8

Native 8-bit signed integer.
##### class Ratio

gmp :: Ratio

Multi precision Rational numbers.
##### enum UInt16

core :: UInt16

Native 16-bit unsigned integer.
##### enum UInt32

core :: UInt32

Native 32-bit unsigned integer.

## Class definitions

##### core \$ Numeric
```# A numeric value supporting mathematical operations
interface Numeric
super Comparable

redef type OTHER: Numeric

# Addition of `self` with `i`
fun +(i: OTHER): OTHER is abstract

# Substraction of `i` from `self`
fun -(i: OTHER): OTHER is abstract

# Inverse of `self`
fun -: OTHER is abstract

# Multiplication of `self` with `i`
fun *(i: OTHER): OTHER is abstract

# Division of `self` with `i`
fun /(i: OTHER): OTHER is abstract

# The integer part of `self`.
#
#     assert (0.0).to_i      == 0
#     assert (0.9).to_i      == 0
#     assert (-0.9).to_i     == 0
#     assert (9.9).to_i      == 9
#     assert (-9.9).to_i     == -9
fun to_i: Int is abstract

# The float equivalent of `self`
#
#     assert 5.to_f         == 5.0
#     assert 5.to_f         != 5 # Float and Int are not equals
fun to_f: Float is abstract

# The byte equivalent of `self`
#
#     assert (-1).to_b == 0xFF.to_b
#     assert (1.9).to_b == 1.to_b
fun to_b: Byte is abstract

# Is this the value of zero in its domain?
fun is_zero: Bool do return self == zero

# The value of zero in the domain of `self`
fun zero: OTHER is abstract

# The value of `val` in the domain of `self`
#
#     assert 1.0.value_of(2) == 2.0
#     assert 1.0.value_of(2.0) == 2.0
#     assert 1.value_of(2) == 2
#     assert 1.value_of(2.0) == 2
fun value_of(val: Numeric): OTHER is abstract
end
```
lib/core/kernel.nit:431,1--486,3
##### core :: fixed_ints \$ Numeric
```redef class Numeric

# The Int8 equivalent of `self`
#
#     assert (-1).to_i8 == 0xFFFFi8
#     assert (1.9).to_i8 == 1i8
fun to_i8: Int8 do return self.to_i.to_i8

# The Int16 equivalent of `self`
#
#     assert (-1).to_i16 == 0xFFFFi16
#     assert (1.9).to_i16 == 1i16
fun to_i16: Int16 do return self.to_i.to_i16

# The UInt16 equivalent of `self`
#
#     assert (-1).to_u16 == 0xFFFFu16
#     assert (1.9).to_u16 == 1u16
fun to_u16: UInt16 do return self.to_i.to_u16

# The Int32 equivalent of `self`
#
#     assert (-1).to_i32 == 0xFFFFFFFFi32
#     assert (1.9).to_i32 == 1i32
fun to_i32: Int32 do return self.to_i.to_i32

# The UInt32 equivalent of `self`
#
#     assert (-1).to_u32 == 0xFFFFFFFFu32
#     assert (1.9).to_u32 == 1u32
fun to_u32: UInt32 do return self.to_i.to_u32

end
```
lib/core/fixed_ints.nit:43,1--75,3
##### core :: numeric \$ Numeric
```redef interface Numeric
# Universal `+` with any `Numeric`
#
# ~~~~
# ~~~~
fun add(other: Numeric): Numeric is abstract

# Universal `-` with any `Numeric`
#
# ~~~~
# assert 2.sub(1) == 1
# assert 1.sub(0.1) == 0.9
# assert 1.1.sub(0.1) == 1.0
# assert 2.1.sub(1) == 1.1
# ~~~~
fun sub(other: Numeric): Numeric is abstract

# Universal `/` with any `Numeric`
#
# ~~~~
# assert 8.div(2) == 4
# assert 4.div(0.5) == 8.0
# assert 1.1.div(0.1) == 11.0
# assert 2.2.div(2) == 1.1
# ~~~~
fun div(other: Numeric): Numeric is abstract

# Universal `*` with any `Numeric`
#
# ~~~~
# assert 2.mul(4) == 8
# assert 11.mul(0.1) == 1.1
# assert 11.1.mul(0.1) == 1.11
# assert 1.1.mul(4) == 4.4
# ~~~~
fun mul(other: Numeric): Numeric is abstract
end
```
lib/core/numeric.nit:43,1--83,3
##### gmp :: gmp \$ Numeric
```redef class Numeric

# The BigInt equivalent of `self`
fun to_bi: BigInt do return self.to_i.to_bi

# The Ratio equivalent of `self`
fun to_r: Ratio do return self.to_f.to_r

end
```
lib/gmp/gmp.nit:20,1--28,3