Defines various values needed to convert integer and floating point values to string representations and vice versa. In addition, this class provides methods that do such conversions on character array buffers.
Defined Singletons and User-Defined Instances:
Two static singletons of this class are defined which can be used whereve r a number format object is needed as a parameter:
'
.', the international standard. Furthermore no group separators are set for decimal and decimal floating point as well as for binary, hexadecimal and octal conversion.User defined objects default to the 'computational' setting after construction.
Output Formats:
The following conversion formats are supported
Notes on Writing and Parsing Values:
not
true for binary, hexadecimal and octal output. In these formats, the width is an absolute value. Higher digits of numbers are just not written. The advantage of this is that no masking is needed when just the lower part of an integer number should be written. However, numbers might of-course change when cut and parsed back later!All of the integer formats have in common that the output width given is including optional grouping characters. For example if a width of 5 was given for decimal output, the value 12
would be written "0,012"
, hence 4 digits plus the grouping character. If grouping was disabled, the output became "00012"
, hence one digit more but the same width. In contrast to that, any sign that is written is not
counted in the width.
When parsing values, grouping characters are ignored at any position within the digits, except of the start. The same is true for whitespace characters as defined in whitespaces. When this field is nulled or empty, then white spaces are not ignored. This might be helpful in some cases where occurrence of white space characters should indicate an error (or something else) when parsing. Otherwise, the characters defined in this field are ignored at two places: at the beginning of a parsing operation and after a sign character was read.
When parsing fails, a value of 0
(respectively 0.0
) is returned. User-friendly classes that use the interface of this type will detect such failure through the output parameter of the parsing methods, which indicates the end of the number found.
For each of the four integer formats, decimal, binary, hexadecimal and octal, dedicated parsing methods exist. Those do not accept literal prefix identifiers as defined in fields binLiteralPrefix, hexLiteralPrefix and octLiteralPrefix. Those are identified by method parseInt, which aggregates the other four parsing methods.
There is no corresponding method defined that writes the literal prefix. When writing binary, hexadecimal or octal values, such prefixes have to be prepended 'manually'.
ALib for Java Specifics:
Public Static Fields | |
static final long | bitsInfNeg = Double.doubleToRawLongBits( Double.NEGATIVE_INFINITY ) |
static final long | bitsInfPos = Double.doubleToRawLongBits( Double.POSITIVE_INFINITY) |
static final long | bitsNaN = Double.doubleToRawLongBits( Double.NaN ) |
static NumberFormat | computational =new NumberFormat() |
static NumberFormat | global =new NumberFormat() |
static final long | signMask |
Public Fields | |
char | binByteGroupChar |
int | binFieldWidth |
com.aworx.lib.strings.AString | binLiteralPrefix |
char | binNibbleGroupChar |
char | binWord32GroupChar |
char | binWordGroupChar |
char | decimalPointChar |
int | decMinimumFieldWidth |
String | exponentSeparator |
boolean | forceDecimalPoint |
boolean | forceScientific |
int | fractionalPartWidth |
char | hexByteGroupChar |
int | hexFieldWidth |
com.aworx.lib.strings.AString | hexLiteralPrefix |
boolean | hexLowerCase |
char | hexWord32GroupChar |
char | hexWordGroupChar |
String | INFLiteral |
int | integralPartMinimumWidth |
char | leadingGroupCharReplacement |
String | NANLiteral |
int | octFieldWidth |
char | octGroupChar |
com.aworx.lib.strings.AString | octLiteralPrefix |
boolean | omitTrailingFractionalZeros |
char | plusSign |
boolean | readGroupChars |
char | thousandsGroupChar |
char[] | whitespaces |
boolean | writeExponentPlusSign |
boolean | writeGroupChars |
Public Static Methods | |
static long | parseDecDigits (char[] buffer, int idx, int maxIdx, int[] newIdx) |
Public Methods | |
NumberFormat () | |
long | parseBin (char[] buffer, int idx, int maxIdx, int[] newIdx) |
long | parseDec (char[] buffer, int idx, int maxIdx, int[] newIdx) |
double | parseFloat (char[] buffer, int idx, int maxIdx, int[] newIdx) |
long | parseHex (char[] buffer, int idx, int maxIdx, int[] newIdx) |
long | parseInt (char[] buffer, int idx, int maxIdx, int[] newIdx) |
long | parseOct (char[] buffer, int idx, int maxIdx, int[] newIdx) |
void | set () |
void | set (NumberFormat other) |
void | setComputational () |
void | setFromLocale () |
int | writeBin (long value, char[] buffer, int idx, int overrideWidth) |
int | writeDecSigned (long value, char[] buffer, int idx, int overrideWidth) |
int | writeDecUnsigned (long value, char[] buffer, int idx, int overrideWidth) |
int | writeFloat (double value, char[] buffer, int idx, int overrideWidth) |
int | writeHex (long value, char[] buffer, int idx, int overrideWidth) |
int | writeOct (long value, char[] buffer, int idx, int overrideWidth) |
Protected Static Fields | |
static int[] | dummyNewIdx = new int[1] |
static char[] | longMinValue = "9#223#372#036#854#775#808".toCharArray() |
static long | pow10_0to18 [] |
Protected Methods | |
int | writeDecUnsignedImpl (long value, char[] buffer, int idx, int width) |
NumberFormat | ( | ) |
Constructor. Invokes setComputational to reset all fields to their default values.
long parseBin | ( | char[] | buffer, |
int | idx, | ||
int | maxIdx, | ||
int[] | newIdx | ||
) |
Reads an unsigned integer value in decimal format from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found. Whitespace and grouping characters, as defined in fields whitespaces, binNibbleGroupChar, binByteGroupChar, binWordGroupChar and binWord32GroupChar will be ignored, regardless on their position between digits. To suppress the parsing of group characters, set the fields to '\0'
. To suppress whitespace consumption, set field whitespaces to null
or empty char
[].
buffer | The character array to read the value from. | |
idx | The start point for parsing within buffer. | |
maxIdx | The maximum index to look at. Must be smaller than the buffers' length. | |
[out] | newIdx | Optional output parameter (in array position 0) that Will be set to point behind the last character consumed. If parsing fails, it will be set to the value of parameter idx which indicates that no parsable number was found. |
long parseDec | ( | char[] | buffer, |
int | idx, | ||
int | maxIdx, | ||
int[] | newIdx | ||
) |
Reads an unsigned integer value in decimal format from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found. Whitespace and grouping characters, as defined in fields whitespaces and thousandsGroupChar will be ignored, regardless on their position between digits. To suppress the parsing of group characters set, field thousandsGroupChar to '\0'
. To suppress whitespace consumption before reading the value, set field whitespaces to nulled or empty string.
Long.MAX_VALUE
in this implementation of ALib.buffer | The character array to read the value from. | |
idx | The start point for parsing within buffer. | |
maxIdx | The maximum index to look at. Must be smaller than the buffers' length. | |
[out] | newIdx | Optional output parameter (in array position 0) that Will be set to point behind the last character consumed. If parsing fails, it will be set to the value of parameter idx which indicates that no parsable number was found. |
|
static |
Static method to read digits '0'
to '9'
into a positive integer value.
buffer | The character array to read the value from. | |
idx | The start point for parsing within buffer. | |
maxIdx | The maximum index to look at. Must be smaller than the buffers' length. | |
[out] | newIdx | Optional output parameter (in array position 0) that Will be set to point behind the last character consumed. If parsing fails, it will be set to the value of parameter idx which indicates that no parsable number was found. |
double parseFloat | ( | char[] | buffer, |
int | idx, | ||
int | maxIdx, | ||
int[] | newIdx | ||
) |
Reads an unsigned integer value in decimal format from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found. and parsing will fail if found.
buffer | The character array to read the value from. |
idx | The start index from where the float value is tried to be parsed. |
maxIdx | The maximum index to look at. Must be smaller than the buffer length. |
newIdx | Optional output variable (in array position 0) that will point to the first character after the integer number that was parsed. If parsing fails, it will be set to the value of parameter idx. Therefore, this parameter can be used to check if a value was found. |
long parseHex | ( | char[] | buffer, |
int | idx, | ||
int | maxIdx, | ||
int[] | newIdx | ||
) |
Reads an unsigned integer value in decimal format from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found. Whitespace and grouping characters, as defined in fields whitespaces, hexByteGroupChar, hexWordGroupChar and hexWord32GroupChar will be ignored, regardless on their position between digits. To suppress the parsing of group characters, set the fields to '\0'
. To suppress whitespace consumption, set field whitespaces to null
or empty char
[].
buffer | The character array to read the value from. | |
idx | The start point for parsing within buffer. | |
maxIdx | The maximum index to look at. Must be smaller than the buffers' length. | |
[out] | newIdx | Optional output parameter (in array position 0) that Will be set to point behind the last character consumed. If parsing fails, it will be set to the value of parameter idx which indicates that no parsable number was found. |
long parseInt | ( | char[] | buffer, |
int | idx, | ||
int | maxIdx, | ||
int[] | newIdx | ||
) |
Parses signed integer numbers, optionally in binary, hexadecimal or octal format.
Leading characters defined in whitespaces are ignored. An optional sign character '+'
or '-'
is parsed. If found, again whitespace characters may follow behind such sign and are ignored.
Then, the method detects any literal prefixes as defined in fields binLiteralPrefix, hexLiteralPrefix and octLiteralPrefix (usually 0b
, 0x
and 0o
) and invokes one of the methods parseDec, parseBin, parseHex or parseOct.
buffer | The character array to read the value from. | |
idx | The start point for parsing within buffer. | |
maxIdx | The maximum index to look at. Must be smaller than the buffers' length. | |
[out] | newIdx | Optional output parameter (in array position 0) that Will be set to point behind the last character consumed. If parsing fails, it will be set to the value of parameter idx which indicates that no parsable number was found. |
long parseOct | ( | char[] | buffer, |
int | idx, | ||
int | maxIdx, | ||
int[] | newIdx | ||
) |
Reads an unsigned integer value in decimal format from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found. Whitespace and grouping characters, as defined in fields whitespaces and octGroupChar will be ignored, regardless on their position between digits. To suppress the parsing of group characters, set the field to '\0'
. To suppress whitespace consumption, set field whitespaces to null
or empty char
[].
buffer | The character array to read the value from. | |
idx | The start point for parsing within buffer. | |
maxIdx | The maximum index to look at. Must be smaller than the buffers' length. | |
[out] | newIdx | Optional output parameter (in array position 0) that Will be set to point behind the last character consumed. If parsing fails, it will be set to the value of parameter idx which indicates that no parsable number was found. |
void set | ( | ) |
Overloaded version of set(NumberFormat) providing default parameter value null
.
void set | ( | NumberFormat | other | ) |
Copies all fields (settings) from the given object. If no object is provided, values of the static singleton found in field global are copied
other | The NumberFormat object to copy the values from. Defaults to null , which chooses the global singleton. |
void setComputational | ( | ) |
Resets the object to its default values. This method is called in the constructor.
Decimal point character and grouping characters are set as follows:
decimalPointChar | . |
thousandsGroupChar | , |
binNibbleGroupChar | ' |
binByteGroupChar | - |
binWordGroupChar | ' ' (space) |
binWord32GroupChar | # |
hexWordGroupChar | ' |
hexWord32GroupChar | ' |
hexByteGroupChar | 0 (none) |
octGroupChar | ' |
The literal attributes are set as follows:
exponentSeparator | "E" |
INFLiteral | "INF" |
NANLiteral | "NAN" |
binLiteralPrefix | "0b" |
hexLiteralPrefix | "0x" |
octLiteralPrefix | "0o" |
All width-attributes are reset to "automatic mode", -1
. The attributes are integralPartMinimumWidth, fractionalPartWidth, decMinimumFieldWidth, binFieldWidth, hexFieldWidth and octFieldWidth.
Finally, the following further fields are reset to their default values:
writeGroupChars | false |
forceScientific | false |
forceDecimalPoint | true |
plusSign | none (0) |
writeExponentPlusSign | false |
omitTrailingFractionalZeros | false |
hexLowerCase | false |
whitespaces | DEFAULT_WHITESPACES |
void setFromLocale | ( | ) |
Sets the field decimalPointChar and thousandsGroupChar to reflect the current system locales' setting. No other values are changed.
int writeBin | ( | long | value, |
char[] | buffer, | ||
int | idx, | ||
int | overrideWidth | ||
) |
Converts the given long value to a string representation in binary format.
Negative numbers have to be converted to positive values when invoking this method. the digits and optional grouping characters. The method does not check any overflow within the given character buffer.
The maximum number of digits written is 64. In addition, grouping characters may be written according the settings of fields writeGroupChars, binNibbleGroupChar, binByteGroupChar, binWordGroupChar, binWord32GroupChar and leadingGroupCharReplacement.
The minimum width of the output is taken from field binFieldWidth unless overwritten by parameter overrideWidth. If the width is greater than digits found in value, '0'
digits are prepended. The width is taking group characters into account.
The literal prefix found in field binLiteralPrefix is not written. The field is only used for detecting formats with method parseInt.
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
overrideWidth | May be used to override value of field binFieldWidth. Defaults to 0 , which denotes to use the fields' value. |
int writeDecSigned | ( | long | value, |
char[] | buffer, | ||
int | idx, | ||
int | overrideWidth | ||
) |
Converts the given long value to a string representation into a signed decimal format.
For negative numbers, '-'
is written, the sign of positive numbers (if any) depends on field plusSign. After that, the value is converted to positive and writeDecUnsigned is invoked.
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
overrideWidth | May be used to override value of field decMinimumFieldWidth. Defaults to 0 , which denotes to use the fields' value. |
int writeDecUnsigned | ( | long | value, |
char[] | buffer, | ||
int | idx, | ||
int | overrideWidth | ||
) |
Converts the given long value to a string representation in decimal format.
Negative numbers have to be converted to positive values when invoking this method. the digits and optional grouping characters. The method does not check any overflow within the given character buffer.
The maximum number of digits written is 19. In addition, grouping characters may be written according the settings of fields writeGroupChars, thousandsGroupChar and leadingGroupCharReplacement.
The minimum width of the output is taken from field decMinimumFieldWidth unless overwritten by parameter overrideWidth. If the width is greater than the sum of digits and grouping characters found in value, then '0'
digits are prepended between the sign and the number.
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
overrideWidth | May be used to override value of field decMinimumFieldWidth. Defaults to 0 , which denotes to use the fields' value. |
|
protected |
Implementation used by writeDecSigned and writeDecUnsigned.
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
width | The overall minimum width to write. |
int writeFloat | ( | double | value, |
char[] | buffer, | ||
int | idx, | ||
int | overrideWidth | ||
) |
Writes the given double value as string representation.
Converts the given long value to a string representation.
Negative numbers have to be converted to positive values when invoking this method. the digits and optional grouping characters. The method does not check any overflow within the given character buffer.
Grouping characters are written according the settings of fields writeGroupChars, thousandsGroupChar and leadingGroupCharReplacement.
The minimum width of the the integral part of the output is taken from field integralPartMinimumWidth unless overwritten by parameter overrideWidth. If the width is greater than integral digits found in value, '0'
digits are prepended. The width is taking group characters into account.
If field fractionalPartWidth as well as the width of the integral part ( provided or set) equals -1
the method may choose scientific notation. This is done, when for numbers smaller than 10E-4
or larger than 10E+6
.
If the given value is not a number, NANLiteral is written. If infinite, INFLiteral.
The output format is dependent on various further settings provided in the fields of this class. Those are decimalPointChar, exponentSeparator, forceDecimalPoint, writeExponentPlusSign and forceScientific
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
overrideWidth | May be used to override value of field integralPartMinimumWidth. Defaults to 0 , which denotes to use the fields' value. |
int writeHex | ( | long | value, |
char[] | buffer, | ||
int | idx, | ||
int | overrideWidth | ||
) |
Converts the given long value to a string representation in hexadecimal format.
Negative numbers have to be converted to positive values when invoking this method. the digits and optional grouping characters. The method does not check any overflow within the given character buffer.
The maximum number of digits written is 16. In addition, grouping characters may be written according the settings of fields writeGroupChars, hexByteGroupChar, hexWordGroupChar, hexWord32GroupChar and leadingGroupCharReplacement.
The minimum width of the output is taken from field hexFieldWidth unless overwritten by parameter overrideWidth. If the width is greater than digits found in value, '0'
digits are prepended. The width is taking group characters into account.
The literal prefix found in field hexLiteralPrefix is not written. The field is only used for detecting formats with method parseInt.
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
overrideWidth | May be used to override value of field hexFieldWidth. Defaults to 0 , which denotes to use the fields' value. |
int writeOct | ( | long | value, |
char[] | buffer, | ||
int | idx, | ||
int | overrideWidth | ||
) |
Converts the given long value to a string representation in octal format.
Negative numbers have to be converted to positive values when invoking this method. the digits and optional grouping characters. The method does not check any overflow within the given character buffer.
The maximum number of digits written is 64. In addition, grouping characters may be written according the settings of fields writeGroupChars, octGroupChar and leadingGroupCharReplacement.
The minimum width of the output is taken from field octFieldWidth unless overwritten by parameter overrideWidth. If the width is greater than digits found in value, '0'
digits are prepended. The width is taking group characters into account.
The literal prefix found in field octLiteralPrefix is not written. The field is only used for detecting formats with method parseInt.
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
overrideWidth | May be used to override value of field octFieldWidth. Defaults to 0 , which denotes to use the fields' value. |
char binByteGroupChar |
Defines the separator character for bytes of binary numbers. Defaults to '\0'
what chooses binNibbleGroupChar.
int binFieldWidth |
Defines the digits written when writing binary values. If the value has less digits, then leading '0' digits are added. If it has more, than those digits are NOT written (!).
The default value and minimum value is -1
, which writes as many bits as necessary.
com.aworx.lib.strings.AString binLiteralPrefix |
Used by method parseInt to detect binary format of integer values. If nulled, no binary format is detected. Methods of this class are not writing the prefix. If desired, this has performed explicitly ("manually") prior to invoking a writing method of this class.
Defaults to "0b"
.
char binNibbleGroupChar |
Defines the separator character for nibbles (4 bits) of binary numbers. Defaults to '\0'
what disables reading and writing of nibble group characters.
char binWord32GroupChar |
Defines the separator character for 32-bit words of binary numbers. Defaults to '\0'
what chooses binWordGroupChar.
char binWordGroupChar |
Defines the separator character for 16-bit words of binary numbers. Defaults to '\0'
what chooses binByteGroupChar.
|
static |
Used for float conversion
|
static |
Used for float conversion
|
static |
Used for float conversion
|
static |
A static number format object that may be used to write and parse numbers for 'computational' use, which means, that grouping is switched off and decimal point character is '
.'.
Method ALIB.init invokes setComputational on this object. Note that using code that use this field without having invoked ALIB.init may behave wrongly.
Classes providing functionality based on this class, might use this as a default value for parameters of their interface methods.
char decimalPointChar |
Defines the decimal point character when converting a floating point number to a string representation with method writeFloat. Also, method parseFloat uses the character provided in this field for parsing the character.
The field defaults to '.'. By invoking setFromLocale(), the current locale's setting is determined.
int decMinimumFieldWidth |
Defines the minimum digits and grouping symbols written when writing integers in decimal. format. If the value to write has less digits (and grouping symbols), then leading '0' digits (and eventually grouping symbols) are added.
If the value to write has more digits, then this field is ignored. A sign character is not calculated into the writing width. To have negative and positive numbers resulting in the same width, plusSign has to be set to a value unequal to '\0'
(usually space character ' '
or '+'
).
If this field is negative, it is ignored. Defaults to -1
.
|
staticprotected |
temporary array used when null is given for 'return value array'.
String exponentSeparator |
Defines the decimal exponent symbol of string representations of floating point numbers when written or parsed in scientific notation by methods parseFloat and writeFloat.
Method parseFloat accepts characters 'e' and 'E' in addition to the string set in this field.
Defaults to 'E'
.
boolean forceDecimalPoint |
If true
, the decimal point of floating point values is written, even if the fractional part of the float value is zero. If false
, in this case the decimal point is omitted.
Defaults to true
.
boolean forceScientific |
If true
, scientific format is always used.
If false
(the default), method writeFloat writes scientific format only if both fields, integralPartMinimumWidth and fractionalPartWidth are evaluating to -1 and only for numbers smaller than 10E-04
or larger than 10E+06
.
If one of the fields integralPartMinimumWidth or fractionalPartWidth is set to a positive value, these limits get extended. Method writeFloat in this case keeps non-scientific notation established if possible.
int fractionalPartWidth |
Defines the number of digits written for the fractional part when converting a floating point value into a string. (For integer conversion, see decMinimumFieldWidth.)
If the fractional part of the number provided has less digits then trailing '0' digits are added.
If the fractional part of the number provided has more digits then the fractional part is rounded accordingly.
The maximum value allowed is 15.
The default value is -1, which writes as many digits as available in the provided float variable, with a minimum of 1 digit.
When either this field or field integralPartMinimumWidth is set to a positive value, the limits to switch to scientific notation, which otherwise are fixed 10E-04
and 10E+06
, get extended. Method writeFloat in this case keeps non-scientific notation established if possible.
|
static |
The default static number format object that acts as the default settings of the currently running process.
Method ALIB.init invokes setFromLocale() on this object and switches grouping on.
Classes providing functionality based on this class, might use this as a default value for parameters of their interface methods.
char hexByteGroupChar |
Defines the separator character for bytes of hexadecimal numbers. Defaults to '\0'
what disables reading and writing of byte group characters.
int hexFieldWidth |
Defines the digits written when writing hexadecimal values. If the value has less digits, then leading '0' digits are added. If it has more, than those digits are NOT written (!).
The default value and minimum value is -1
, which writes as many bits as necessary.
com.aworx.lib.strings.AString hexLiteralPrefix |
Used by method parseInt to detect hexadecimal format of integer values. If nulled, no hexadecimal format is detected. Methods of this class are not writing the prefix. If desired, this has performed explicitly ("manually") prior to invoking a writing method of this class.
Defaults to "0x"
.
boolean hexLowerCase |
If true
, lower case letters 'a'
- 'f'
are written. Defaults to false
, which writes upper case letters 'A'
- 'F'
.
char hexWord32GroupChar |
Defines the separator character for 32-bit words of hexadecimal numbers. Defaults to '\0'
what chooses hexWordGroupChar.
char hexWordGroupChar |
Defines the separator character for 16-bit words of hexadecimal numbers. Defaults to '\0'
what chooses hexByteGroupChar.
String INFLiteral |
Defines what is written and parsed for infinite double values.
int integralPartMinimumWidth |
Defines the minimum digits written for the integral part when converting a floating point value into a string.
If the integral part of the number provided has less digits then leading '0' digits are added.
The maximum value allowed is 15.
A value of 0 leads to omitting the '0' before the decimal separator in the case the value is below 1.0 and higher than -1.0
The default value is -1, which writes a minimum of 1 digit.
When either this field or field fractionalPartWidth is set to a positive value, the limits to switch to scientific notation, which otherwise are fixed 10E-04
and 10E+06
, get extended. Method writeFloat in this case keeps non-scientific notation established if possible.
char leadingGroupCharReplacement |
This character is written instead of a grouping character in the case that a certain output width is requested but a grouping character would be the first character to write. Writing this character instead, assures the field width be as requested. Defaults to space (' '
).
|
staticprotected |
Special treatment for Long.MIN_VALUE: can not be converted to positive.
String NANLiteral |
Defines what is written and parsed for double values that represent "not a number".
int octFieldWidth |
Defines the digits written when writing hexadecimal values. If the value has less digits, then leading '0' digits are added. If it has more, than those digits are NOT written (!).
The default value and minimum value is -1
, which writes as many bits as necessary.
char octGroupChar |
Defines the separator character for bytes of hexadecimal numbers. Defaults to '
, Defaults to '\0'
what disables reading and writing of byte group characters.
com.aworx.lib.strings.AString octLiteralPrefix |
Used by method parseInt to detect octal format of integer values. If nulled, no octal format is detected. Methods of this class are not writing the prefix. If desired, this has performed explicitly ("manually") prior to invoking a writing method of this class.
Defaults to "0o"
.
boolean omitTrailingFractionalZeros |
If this field is true
, then trailing '0'
digits in the fractional part of a floating point value are not written, even if a fractionalPartWidth is set. Defaults to false
.
char plusSign |
Determines if positive values are prepended with an explicit character (usually '+') when written using writeFloat or writeDecSigned.
Defaults to 0
which omits the writing. Usual other values are of-course '+'
, but also ' '
(space) which supports better horizontal alignment of numbers when written in columns. Note that this is not affecting exponent decimals of floating point values. For those, see writeExponentPlusSign
|
staticprotected |
Constant long values for 10 ^(0...18) needed by conversion methods.
boolean readGroupChars |
Denotes if grouping characters are ignored when parsing numbers if they are given (not set to '\0'
). This applies to all number types.
Defaults to false
. If set to true
, grouping characters are just skipped when found while parsing numbers, no matter at which position they occur.
|
static |
Used for float conversion
char thousandsGroupChar |
Defines the separator character for thousands when converting a number to a string representation. In addition, this is used to identify thousand group symbols when parsing decimal values. If set to '\0'
, no group separator is written and also when parsing, a group separator is not accepted. If set, still writeGroupChars controls if it is written.
Defaults to '
,'. By invoking setFromLocale(), the current locale's setting is determined.
char [] whitespaces |
Defines whitespace characters that are ignored when leading the number and after the sign-character. Applies to methods parseInt and parseFloat. In contrast, methods parseDec, parseBin, parseHex and parseOct do not ignore any whitespace characters.
boolean writeExponentPlusSign |
Determines if positive exponent values are prepended with an explicit '+' character when written using writeFloat.
Defaults to false, as some systems will not accept a plus sign on the exponent value. Note that field plusSign is not applicable for exponent numbers.
boolean writeGroupChars |
Denotes if grouping characters are written if they are given (not set to '\0'
). This applies to all number types.
Defaults to false
.