public final class SizeExpression extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
MULTIPLIER_10
The Constant MULTIPLIER_10.
|
static long |
MULTIPLIER_2
The Constant MULTIPLIER_2.
|
static char |
PREFIX_GIGA
The Constant PREFIX_GIGA.
|
static char |
PREFIX_KILO
The Constant PREFIX_KILO.
|
static char |
PREFIX_MEGA
The Constant PREFIX_MEGA.
|
static char |
PREFIX_PETA
The Constant PREFIX_PETA.
|
static char |
PREFIX_TERA
The Constant PREFIX_TERA.
|
static String |
UNIT_BASE
The Constant UNIT_BASE.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
format(long value,
int decimalPlaces,
boolean base2)
Formats the value as an expression.
|
static long |
parse(String expression)
Parses the given expression into a numerical value.
|
public static final long MULTIPLIER_2
public static final long MULTIPLIER_10
public static final String UNIT_BASE
public static final char PREFIX_KILO
public static final char PREFIX_MEGA
public static final char PREFIX_GIGA
public static final char PREFIX_TERA
public static final char PREFIX_PETA
public static long parse(String expression)
An expression has three parts:
| Name | Description |
|---|---|
| Base Number | (Required) The mantissa or significand of the expression. This can include decimal values. |
| Prefix | (Optional) The SI prefix. These span from K for kilo- to P for peta-. |
| Unit | (Optional) If the unit "B" (for bytes) is provided, the prefix is treated as base-2 (1024). Otherwise, it uses base-10 (1000). |
| Note: Whitespace may or may not exist between the Base Number and Prefix. | |
Examples:
2000350000020483670016expression - the expression to parseNumberFormatException - if the given expression cannot be parsedpublic static String format(long value, int decimalPlaces, boolean base2)
value - the numerical value to be formatteddecimalPlaces - the number of decimal places in the mantissabase2 - whether to use the base-2 (1024) multiplier and format with "B" units. If false,
uses the base-10 (1000) multiplier and no units.Copyright © 2009–2020 psi-probe. All rights reserved.