ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Static Fields | Public Fields | Public Static Methods | Public Methods | Protected Static Fields | Protected Methods | List of all members
NumberFormat Class Reference
Collaboration diagram for NumberFormat:
[legend]

Class Description


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.

Attention
The methods of this class are not intended for the common use. Instead, use interface of classes AString, Substring or Formatter to write and parse numbers, which accept an object of this type as parameters.

Defined Singletons and User-Defined Instances:
Two static singletons of this class are defined which can be used wherever a number format object is needed as a parameter:

User defined objects default to the 'computational' setting after construction.

Output Formats:
The following conversion formats are supported

Notes on Writing and Parsing Values:

Attention
For decimal output, the width (DecMinimumFieldWidth) is a minimum width. This mean, that bigger numbers are written in a higher width. This is 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'.

Public Static Fields

static readonly long BitsInfNeg = BitConverter.DoubleToInt64Bits( Double.NegativeInfinity )
 
static readonly long BitsInfPos = BitConverter.DoubleToInt64Bits( Double.PositiveInfinity)
 
static readonly long BitsNaN = BitConverter.DoubleToInt64Bits( Double.NaN )
 
static NumberFormat Computational =new NumberFormat()
 
static NumberFormat Global =new NumberFormat()
 
static readonly long SignMask
 

Public Fields

char BinByteGroupChar
 
int BinFieldWidth
 
AString BinLiteralPrefix
 
char BinNibbleGroupChar
 
char BinWord32GroupChar
 
char BinWordGroupChar
 
char DecimalPointChar
 
int DecMinimumFieldWidth
 
String ExponentSeparator
 
bool ForceDecimalPoint
 
bool ForceScientific
 
int FractionalPartWidth
 
char HexByteGroupChar
 
int HexFieldWidth
 
AString HexLiteralPrefix
 
bool HexLowerCase
 
char HexWord32GroupChar
 
char HexWordGroupChar
 
String INFLiteral
 
int IntegralPartMinimumWidth
 
char LeadingGroupCharReplacement
 
String NANLiteral
 
int OctFieldWidth
 
char OctGroupChar
 
AString OctLiteralPrefix
 
bool OmitTrailingFractionalZeros
 
char PlusSign
 
bool ReadGroupChars
 
char ThousandsGroupChar
 
char[] Whitespaces = CString.DefaultWhitespaces
 
bool WriteExponentPlusSign
 
bool WriteGroupChars
 

Public Static Methods

static ulong ParseDecDigits (char[] buffer, ref int idx, int maxIdx)
 

Public Methods

 NumberFormat ()
 
ulong ParseBin (char[] buffer, ref int idx, int maxIdx)
 
ulong ParseDec (char[] buffer, ref int idx, int maxIdx)
 
double ParseFloat (char[] buffer, ref int idx, int maxIdx)
 
ulong ParseHex (char[] buffer, ref int idx, int maxIdx)
 
long ParseInt (char[] buffer, ref int idx, int maxIdx)
 
ulong ParseOct (char[] buffer, ref int idx, int maxIdx)
 
void Set (NumberFormat other=null)
 
void SetComputational ()
 
void SetFromLocale ()
 
int WriteBin (ulong value, char[] buffer, int idx, int overrideWidth)
 
int WriteDecSigned (long value, char[] buffer, int idx, int overrideWidth)
 
int WriteDecUnsigned (ulong value, char[] buffer, int idx, int overrideWidth)
 
int WriteFloat (double value, char[] buffer, int idx, int overrideWidth)
 
int WriteHex (ulong value, char[] buffer, int idx, int overrideWidth)
 
int WriteOct (ulong value, char[] buffer, int idx, int overrideWidth)
 

Protected Static Fields

static readonly ulong[] pow10_0to19
 

Protected Methods

int writeDecUnsigned (ulong value, char[] buffer, int idx, int width)
 

Constructor & Destructor Documentation

◆ NumberFormat()

NumberFormat ( )
inline

Constructor. Invokes SetComputational to reset all fields to their default values.

Member Function Documentation

◆ ParseBin()

ulong ParseBin ( char[]  buffer,
ref int  idx,
int  maxIdx 
)
inline

Reads an unsigned (64bit) 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[].

Parameters
bufferThe string to read the value from.
[in,out]idxThe start point for parsing within buffer. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found.
maxIdxThe maximum index to look at. Must be smaller than the buffers' length.
Returns
The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.

◆ ParseDec()

ulong ParseDec ( char[]  buffer,
ref int  idx,
int  maxIdx 
)
inline

Reads an unsigned (64bit) 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.

Parameters
bufferThe string to read the value from.
[in,out]idxThe start point for parsing within buffer. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found.
maxIdxThe maximum index to look at. Must be smaller than the buffers' length.
Returns
The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.

◆ ParseDecDigits()

static ulong ParseDecDigits ( char[]  buffer,
ref int  idx,
int  maxIdx 
)
inlinestatic

Static method to read digits '0' to '9' into a positive integer value.

Parameters
bufferThe string to read the value from.
[in,out]idxThe start point for parsing within buffer. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found.
maxIdxThe maximum index to look at. Must be smaller than the buffers' length.
Returns
The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.

◆ ParseFloat()

double ParseFloat ( char[]  buffer,
ref int  idx,
int  maxIdx 
)
inline

Reads an unsigned (64bit) 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.

Parameters
bufferThe string to read the value from.
[in,out]idxThe start point for parsing within buffer. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found.
maxIdxThe maximum index to look at. Must be smaller than the buffers' length.
Returns
The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.

◆ ParseHex()

ulong ParseHex ( char[]  buffer,
ref int  idx,
int  maxIdx 
)
inline

Reads an unsigned (64bit) 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[].

Parameters
bufferThe string to read the value from.
[in,out]idxThe start point for parsing within buffer. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found.
maxIdxThe maximum index to look at. Must be smaller than the buffers' length.
Returns
The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.

◆ ParseInt()

long ParseInt ( char[]  buffer,
ref int  idx,
int  maxIdx 
)
inline

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.

Parameters
bufferThe string to read the value from.
[in,out]idxThe start point for parsing within buffer. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found.
maxIdxThe maximum index to look at. Must be smaller than the buffers' length.
Returns
The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.

◆ ParseOct()

ulong ParseOct ( char[]  buffer,
ref int  idx,
int  maxIdx 
)
inline

Reads an unsigned (64bit) 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[].

Parameters
bufferThe string to read the value from.
[in,out]idxThe start point for parsing within buffer. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found.
maxIdxThe maximum index to look at. Must be smaller than the buffers' length.
Returns
The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.

◆ Set()

void Set ( NumberFormat  other = null)
inline

Copies all fields (settings) from the given object. If no object is provided, values of the static singleton found in field Global are copied

Parameters
otherThe NumberFormat object to copy the values from. Defaults to null, which chooses the global singleton.

◆ SetComputational()

void SetComputational ( )
inline

Resets the object to its default values. This method is called in the constructor.

Decimal point character and grouping characters are set as follows:

Field
Value
DecimalPointChar .
ThousandsGroupChar ,
BinNibbleGroupChar '
BinByteGroupChar -
BinWordGroupChar ' ' (space)
BinWord32GroupChar #
HexWordGroupChar '
HexWord32GroupChar '
HexByteGroupChar 0 (none)
OctGroupChar '

The literal attributes are set as follows:

Field
Value
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:

Field
Value
WriteGroupChars false
ForceScientific false
ForceDecimalPoint true
PlusSign none (0)
WriteExponentPlusSign false
OmitTrailingFractionalZeros false
HexLowerCase false
Whitespaces DefaultWhitespaces
Note
With static object NumberFormat.Computational, there is a global singleton existing which can be used but must not be changed.

◆ SetFromLocale()

void SetFromLocale ( )
inline

Sets the field DecimalPointChar and ThousandsGroupChar to reflect the current system locales' setting. No other values are changed.

Note
Static (global) object NumberFormat.Global, implements an instance which has the right locale set (provided that ALIB.Init was duly invoked by the process). Otherwise, this method might be used to initialize a custom object with default values to afterwards make some specific changes.

◆ WriteBin()

int WriteBin ( ulong  value,
char[]  buffer,
int  idx,
int  overrideWidth 
)
inline

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.

Attention
If the value is greater than can be represented by the output width, these greater digits are cut. This is true for this method as well as WriteHex and WriteOct. The rational behind this is that this way, larger numbers do not need to be masked before writing. (In other words: it is assumed that there is a reason for providing the width).

The literal prefix found in field BinLiteralPrefix is not written. The field is only used for detecting formats with method ParseInt.

Parameters
valueThe value to write.
bufferThe character array to write the value to. Needs to be long enough (after idx) to carry the string written.
idxThe index within buffer to start writing.
overrideWidthMay be used to override value of field BinFieldWidth. Defaults to 0, which denotes to use the fields' value.
Returns
The index pointing to behind the last character written in buffer.

◆ WriteDecSigned()

int WriteDecSigned ( long  value,
char[]  buffer,
int  idx,
int  overrideWidth 
)
inline

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.

Parameters
valueThe value to write.
bufferThe character array to write the value to. Needs to be long enough (after idx) to carry the string written.
idxThe index within buffer to start writing.
overrideWidthMay be used to override value of field DecMinimumFieldWidth. Defaults to 0, which denotes to use the fields' value.
Returns
The index pointing to behind the last character written in buffer.

◆ WriteDecUnsigned()

int WriteDecUnsigned ( ulong  value,
char[]  buffer,
int  idx,
int  overrideWidth 
)
inline

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 20. 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.

Parameters
valueThe value to write.
bufferThe character array to write the value to. Needs to be long enough (after idx) to carry the string written.
idxThe index within buffer to start writing.
overrideWidthMay be used to override value of field DecMinimumFieldWidth. Defaults to 0, which denotes to use the fields' value.
Returns
The index pointing to behind the last character written in buffer.

◆ writeDecUnsigned()

int writeDecUnsigned ( ulong  value,
char[]  buffer,
int  idx,
int  width 
)
inlineprotected

Implementation used by WriteDecSigned and WriteDecUnsigned.

Parameters
valueThe value to write.
bufferThe character array to write the value to. Needs to be long enough (after idx) to carry the string written.
idxThe index within buffer to start writing.
widthThe overall minimum width to write.
Returns
The index pointing to behind the last character written in buffer.

◆ WriteFloat()

int WriteFloat ( double  value,
char[]  buffer,
int  idx,
int  overrideWidth 
)
inline

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

Parameters
valueThe value to write.
bufferThe character array to write the value to. Needs to be long enough (after idx) to carry the string written.
idxThe index within buffer to start writing.
overrideWidthMay be used to override value of field IntegralPartMinimumWidth. Defaults to 0, which denotes to use the fields' value.
Returns
The index pointing to behind the last character written in buffer.

◆ WriteHex()

int WriteHex ( ulong  value,
char[]  buffer,
int  idx,
int  overrideWidth 
)
inline

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.

Attention
If the value is greater than can be represented by the output width, these greater digits are cut. This is true for this method as well as WriteBin and writeOct. The rational behind this is that this way, larger numbers do not need to be masked before writing. (In other words: it is assumed that there is a reason for providing the width).

The literal prefix found in field HexLiteralPrefix is not written. The field is only used for detecting formats with method ParseInt.

Parameters
valueThe value to write.
bufferThe character array to write the value to. Needs to be long enough (after idx) to carry the string written.
idxThe index within buffer to start writing.
overrideWidthMay be used to override value of field HexFieldWidth. Defaults to 0, which denotes to use the fields' value.
Returns
The index pointing to behind the last character written in buffer.

◆ WriteOct()

int WriteOct ( ulong  value,
char[]  buffer,
int  idx,
int  overrideWidth 
)
inline

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.

Attention
If the value is greater than can be represented by the output width, these greater digits are cut. This is true for this method as well as WriteBin and writeHex. The rational behind this is that this way, larger numbers do not need to be masked before writing. (In other words: it is assumed that there is a reason for providing the width).

The literal prefix found in field OctLiteralPrefix is not written. The field is only used for detecting formats with method ParseInt.

Parameters
valueThe value to write.
bufferThe character array to write the value to. Needs to be long enough (after idx) to carry the string written.
idxThe index within buffer to start writing.
overrideWidthMay be used to override value of field OctFieldWidth. Defaults to 0, which denotes to use the fields' value.
Returns
The index pointing to behind the last character written in buffer.

Member Data Documentation

◆ BinByteGroupChar

char BinByteGroupChar

Defines the separator character for bytes of binary numbers. Defaults to '\0' what chooses BinNibbleGroupChar.

◆ BinFieldWidth

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.

◆ BinLiteralPrefix

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".

◆ BinNibbleGroupChar

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.

◆ BinWord32GroupChar

char BinWord32GroupChar

Defines the separator character for 32-bit words of binary numbers. Defaults to '\0' what chooses BinWordGroupChar.

◆ BinWordGroupChar

char BinWordGroupChar

Defines the separator character for 16-bit words of binary numbers. Defaults to '\0' what chooses BinByteGroupChar.

◆ BitsInfNeg

readonly long BitsInfNeg = BitConverter.DoubleToInt64Bits( Double.NegativeInfinity )
static

Bit mask to detect negative infinite values from raw values.

◆ BitsInfPos

readonly long BitsInfPos = BitConverter.DoubleToInt64Bits( Double.PositiveInfinity)
static

Bit mask to detect positive infinite values from raw values.

◆ BitsNaN

readonly long BitsNaN = BitConverter.DoubleToInt64Bits( Double.NaN )
static

Bit mask to detect NaN values from raw values.

◆ Computational

NumberFormat Computational =new NumberFormat()
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.

◆ DecimalPointChar

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.

◆ DecMinimumFieldWidth

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.

◆ ExponentSeparator

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'.

◆ ForceDecimalPoint

bool 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.

◆ ForceScientific

bool 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.

◆ FractionalPartWidth

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.

◆ Global

NumberFormat Global =new NumberFormat()
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.

◆ HexByteGroupChar

char HexByteGroupChar

Defines the separator character for bytes of hexadecimal numbers. Defaults to '\0' what disables reading and writing of byte group characters.

◆ HexFieldWidth

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.

◆ HexLiteralPrefix

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 "0bx".

◆ HexLowerCase

bool HexLowerCase

If true, lower case letters 'a' - 'f' are written. Defaults to false, which writes upper case letters 'A' - 'F'.

◆ HexWord32GroupChar

char HexWord32GroupChar

Defines the separator character for 32-bit words of hexadecimal numbers. Defaults to '\0' what chooses HexWordGroupChar.

◆ HexWordGroupChar

char HexWordGroupChar

Defines the separator character for 16-bit words of hexadecimal numbers. Defaults to '\0' what chooses HexByteGroupChar.

◆ INFLiteral

String INFLiteral

Defines what is written and parsed for infinite double values.

◆ IntegralPartMinimumWidth

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.

◆ LeadingGroupCharReplacement

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 (' ').

◆ NANLiteral

String NANLiteral

Defines what is written and parsed for double values that represent "not a number".

◆ OctFieldWidth

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.

◆ OctGroupChar

char OctGroupChar

Defines the separator character for bytes of hexadecimal numbers. Defaults to '\0' what disables reading and writing of byte group characters.

◆ OctLiteralPrefix

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".

◆ OmitTrailingFractionalZeros

bool 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.

◆ PlusSign

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

◆ pow10_0to19

readonly ulong [] pow10_0to19
staticprotected
Initial value:
=
{
1UL,
10UL,
100UL,
1000UL,
10000UL,
100000UL,
1000000UL,
10000000UL,
100000000UL,
1000000000UL,
10000000000UL,
100000000000UL,
1000000000000UL,
10000000000000UL,
100000000000000UL,
1000000000000000UL,
10000000000000000UL,
100000000000000000UL,
1000000000000000000UL,
10000000000000000000UL,
}

Constant long values for 10 ^(0...18) needed by conversion methods.

◆ ReadGroupChars

bool 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.

◆ SignMask

readonly long SignMask
static
Initial value:
= BitConverter.DoubleToInt64Bits(-0.0)
^ BitConverter.DoubleToInt64Bits(+0.0)

Bit mask to detect the sign from raw values.

◆ ThousandsGroupChar

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.

◆ 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.

◆ WriteExponentPlusSign

bool 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.

◆ WriteGroupChars

bool WriteGroupChars

Denotes if grouping characters are written if they are given (not set to '\0'). This applies to all number types.
Defaults to false.


The documentation for this class was generated from the following file: