java.lang.Object
org.kink_lang.kink.internal.num.NumOperations
Number operations used in Kink.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getElemIndex
(BigDecimal num, int size) Returns the exact int value of the num, if the num is a proper element index in the sequence which has the sizesize
, otherwise returns -1.static int
getElemIndex
(Val val, int size) Returns the exact int value of the val, if the val is a NumVal and it represents a valid element index exactly in the sequence which has the sizesize
, otherwise returns -1.static BigInteger
getExactBigInteger
(Val val) Returns an exact BigInteger from the val, if the val is a NumVal and it represents an int number.static OptionalInt
getExactInt
(Val val) Returns an exact int number from the val, if the val is a NumVal and it represents the exact int number.static OptionalLong
getExactLongBetween
(Val val, long min, long max) Returns an exact long number from the val, if the val is a NumVal and it represents the exact long number betweenmin
andmax
.static int
getPosIndex
(BigDecimal num, int size) Returns the exact int value of the num, if the num is a proper pos index in the sequence which has the sizesize
, otherwise returns -1.static int
getPosIndex
(Val val, int size) Returns the exact int value of the val, if the val is a NumVal and it represents a valid position index exactly in the sequence which has the sizesize
, otherwise returns -1.static int
hash
(BigDecimal num) Returns num.hash.static boolean
isRangePair
(BigDecimal from, BigDecimal to, int size) Returns whetherfrom
andto
are proper range indexes of the sequence which has the sizesize
.
-
Method Details
-
hash
Returns num.hash.- Parameters:
num
- the num to hash.- Returns:
- the hash used in Kink.
-
getElemIndex
Returns the exact int value of the num, if the num is a proper element index in the sequence which has the sizesize
, otherwise returns -1.- Parameters:
num
- the num.size
- the size of a sequence.- Returns:
- the exact int value of the num, or -1.
-
getElemIndex
Returns the exact int value of the val, if the val is a NumVal and it represents a valid element index exactly in the sequence which has the sizesize
, otherwise returns -1.- Parameters:
val
- the val from which the index is extracted.size
- the size of a sequence.- Returns:
- the exact int number of the val, or -1.
-
getPosIndex
Returns the exact int value of the num, if the num is a proper pos index in the sequence which has the sizesize
, otherwise returns -1.- Parameters:
num
- the num.size
- the size of a sequence.- Returns:
- the exact int value of the num, or -1.
-
getPosIndex
Returns the exact int value of the val, if the val is a NumVal and it represents a valid position index exactly in the sequence which has the sizesize
, otherwise returns -1.- Parameters:
val
- the val from which the index is extracted.size
- the size of a sequence.- Returns:
- the exact int number of the val, or -1.
-
getExactInt
Returns an exact int number from the val, if the val is a NumVal and it represents the exact int number.- Parameters:
val
- the val from which the int number is extracted.- Returns:
- the exact int number, or empty.
-
getExactLongBetween
Returns an exact long number from the val, if the val is a NumVal and it represents the exact long number betweenmin
andmax
.- Parameters:
val
- the val the long number from which is extracted.min
- the minimum of the range.max
- the maximum of the range.- Returns:
- the exact long number, or empty.
-
getExactBigInteger
Returns an exact BigInteger from the val, if the val is a NumVal and it represents an int number.- Parameters:
val
- the val from which the BigInteger is extracted.- Returns:
- the exact BigInteger, or null.
-
isRangePair
Returns whetherfrom
andto
are proper range indexes of the sequence which has the sizesize
.- Parameters:
from
- the from index.to
- the to index.size
- the size of a sequence.- Returns:
- true if
from
andto
are proper range indexes.
-