public final class NumberInput
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NASTY_SMALL_DOUBLE
Textual representation of a double constant that can cause nasty problems
with JDK (see http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308).
|
Constructor and Description |
---|
NumberInput() |
Modifier and Type | Method and Description |
---|---|
static boolean |
inLongRange(char[] ch,
int off,
int len,
boolean negative)
Helper method for determining if given String representation of
an integral number would fit in 64-bit Java long or not.
|
static boolean |
inLongRange(java.lang.String s,
boolean negative)
Similar to
inLongRange(char[],int,int,boolean) , but
with String argument |
static double |
parseAsDouble(java.lang.String s,
double def) |
static int |
parseAsInt(java.lang.String s,
int def) |
static long |
parseAsLong(java.lang.String s,
long def) |
static java.math.BigDecimal |
parseBigDecimal(char[] b) |
static java.math.BigDecimal |
parseBigDecimal(char[] b,
int off,
int len) |
static java.math.BigDecimal |
parseBigDecimal(java.lang.String s) |
static double |
parseDouble(java.lang.String s) |
static int |
parseInt(char[] ch,
int off,
int len)
Fast method for parsing integers that are known to fit into
regular 32-bit signed int type.
|
static int |
parseInt(java.lang.String s)
Helper method to (more) efficiently parse integer numbers from
String values.
|
static long |
parseLong(char[] ch,
int off,
int len) |
static long |
parseLong(java.lang.String s) |
public static final java.lang.String NASTY_SMALL_DOUBLE
public static int parseInt(char[] ch, int off, int len)
Note: public to let unit tests call it
public static int parseInt(java.lang.String s)
public static long parseLong(char[] ch, int off, int len)
public static long parseLong(java.lang.String s)
public static boolean inLongRange(char[] ch, int off, int len, boolean negative)
negative
- Whether original number had a minus sign (which is
NOT passed to this method) or notpublic static boolean inLongRange(java.lang.String s, boolean negative)
inLongRange(char[],int,int,boolean)
, but
with String argumentnegative
- Whether original number had a minus sign (which is
NOT passed to this method) or notpublic static int parseAsInt(java.lang.String s, int def)
public static long parseAsLong(java.lang.String s, long def)
public static double parseAsDouble(java.lang.String s, double def)
public static double parseDouble(java.lang.String s) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public static java.math.BigDecimal parseBigDecimal(java.lang.String s) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public static java.math.BigDecimal parseBigDecimal(char[] b) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public static java.math.BigDecimal parseBigDecimal(char[] b, int off, int len) throws java.lang.NumberFormatException
java.lang.NumberFormatException
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"