Interface NumberDefinition
- All Known Subinterfaces:
AccessScalar<N>, AggregatorFunction<N>, BigFunction.Nullary, ComparableNumber<N>, ComplexFunction.Nullary, ElementView1D<N,V>, ElementView2D<N, V>, ElementViewAnyD<N, V>, EntryPair.KeyedPrimitive<K>, NullaryFunction<N>, PrimitiveFunction.Nullary, PrimitiveNumber, QuadrupleFunction.Nullary, QuaternionFunction.Nullary, RationalFunction.Nullary, Scalar<N>, SelfDeclaringScalar<S>
- All Known Implementing Classes:
AbstractContinuous, AbstractDiscrete, Access1D.ElementView, Access2D.ElementView, AccessAnyD.ElementView, AggregatorFunction.PredicateWrapper, AlphaVantageParser.Data, Amount, BigAggregator.BigAggregatorFunction, BigScalar, BinaryFunction.FixedFirst, BinaryFunction.FixedSecond, Binomial, CalendarDateDuration, Cauchy, ChiSquareDistribution, ChiSquareDistribution.Degree2, ChiSquareDistribution.NormalApproximation, ComplexAggregator.ComplexAggregatorFunction, ComplexNumber, DatePrice, DatePrice.DefaultDP, Deterministic, EntryPair.ObjectByte, EntryPair.ObjectDouble, EntryPair.ObjectFloat, EntryPair.ObjectInt, EntryPair.ObjectLong, EntryPair.ObjectShort, Erlang, ExactDecimal, Exponential, Gamma, Geometric, IEXTradingParser.Data, LogNormal, Money, Normal, Poisson, Price, PrimitiveAggregator.PrimitiveAggregatorFunction, PrimitiveNumber.BoxedByte, PrimitiveNumber.BoxedDouble, PrimitiveNumber.BoxedFloat, PrimitiveNumber.BoxedInt, PrimitiveNumber.BoxedLong, PrimitiveNumber.BoxedShort, PrimitiveScalar, Quadruple, QuadrupleAggregator.QuadrupleAggregatorFunction, Quantity, Quaternion, QuaternionAggregator.QuaternionAggregatorFunction, R064CSC.NonZeroView, R064CSR.NonZeroView, RandomNumber, RationalAggregator.RationalAggregatorFunction, RationalNumber, SparseArray.NonzeroView, TDistribution, TDistribution.Degree1, TDistribution.Degree2, TDistribution.Degree3, TDistribution.Degree4, TDistribution.Degree5, TDistribution.DegreeInfinity, Uniform, Weibull, YahooParser.Data
Number been an interface...-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanstatic booleanbooleanValue(Comparable<?> number) default bytestatic bytebyteValue(Comparable<?> number) doublestatic doubledoubleValue(Comparable<?> number) default floatstatic floatfloatValue(Comparable<?> number) default intintValue()static intintValue(Comparable<?> number) default longstatic longlongValue(Comparable<?> number) static doubleparseDouble(CharSequence sequence) Parses aCharSequenceinto a double.static floatparseFloat(CharSequence sequence) Similar toparseDouble(CharSequence)but for float, and thus limited to 7 digits after the decimal point.static intparseInt(CharSequence sequence) Similar toparseDouble(CharSequence)andparseLong(CharSequence)but for int.static longparseLong(CharSequence sequence) Similar toparseDouble(CharSequence)but for long.static shortparseShort(CharSequence sequence) Similar toparseDouble(CharSequence)andparseLong(CharSequence)but for short.default shortstatic shortshortValue(Comparable<?> number) static booleantoBoolean(int value) static inttoInt(double value) static inttoInt(float value) static longtoLong(double value)
-
Method Details
-
booleanValue
-
byteValue
-
doubleValue
-
floatValue
-
intValue
-
longValue
-
parseDouble
Parses aCharSequenceinto a double. Only plain and simple numbers are supported – no scientific notation, no hexadecimal notation, no octal notation, no binary notation, no fractions, no exponents, no grouping, no leading or trailing whitespace, no commas, no underscores, no currency symbols, no NaN, no positive or negative infinity or anything else fancy – just plain and simple numbers.If the
CharSequenceis null aNullPointerExceptionis thrown.If it's empty, length zero, zero is returned.
If it contains any characters other than '+', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8' or '9' the return value is undefined.
If any of the characters '+', '-' or '.' appears more than once the return value is undefined.
If both '+' and '-' appear the return value is undefined.
If there are more than 16 digits after the decimal point the return value is undefined.
This method does not throw any exceptions (other than that eventual
NullPointerException). Nor does it do any error checking.This method is more than 10 times faster than
Double.parseDouble(String). It takes aCharSequence, rather thanString, as input. Further more it does not create any garbage (no intermediate objects created). -
parseFloat
Similar toparseDouble(CharSequence)but for float, and thus limited to 7 digits after the decimal point. It is almost 10 times faster thanFloat.parseFloat(String).- See Also:
-
parseInt
Similar toparseDouble(CharSequence)andparseLong(CharSequence)but for int.- See Also:
-
parseLong
Similar toparseDouble(CharSequence)but for long. Performs roughly the same asLong.parseLong(String), but takes aCharSequence, rather thanString, as input.- See Also:
-
parseShort
Similar toparseDouble(CharSequence)andparseLong(CharSequence)but for short.- See Also:
-
shortValue
-
toBoolean
static boolean toBoolean(int value) -
toInt
static int toInt(double value) -
toInt
static int toInt(float value) -
toLong
static long toLong(double value) -
booleanValue
default boolean booleanValue() -
byteValue
default byte byteValue() -
doubleValue
double doubleValue() -
floatValue
default float floatValue() -
intValue
default int intValue() -
longValue
default long longValue() -
shortValue
default short shortValue()
-