|
Real.java v1.13 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ral.Real.NumberFormat
public static class Real.NumberFormat
The number format used to convert Real
values to
String
using Real.toString()
. The default number format uses base-10, maximum
precision, removal of trailing zeros and '.' as radix point.
Note that the fields of NumberFormat
are not
protected in any way, the user is responsible for setting the
correct values to get a correct result.
Field Summary | |
---|---|
int |
align
The alignment of the output string within a field of maxwidth characters. |
static int |
ALIGN_CENTER
Center alignment |
static int |
ALIGN_LEFT
Left alignment |
static int |
ALIGN_NONE
No alignment |
static int |
ALIGN_RIGHT
Right alignment |
int |
base
The number base of the conversion. |
int |
fse
The special output formats FIX, SCI or ENG are enabled with this field. |
static int |
FSE_ENG
ENG output format |
static int |
FSE_FIX
FIX output format |
static int |
FSE_NONE
Normal output format |
static int |
FSE_SCI
SCI output format |
int |
maxwidth
Maximum width of the converted string. |
char |
point
The character used as the radix point. |
int |
precision
The precision, or number of digits after the radix point in the converted string when using the FIX, SCI or ENG format (see fse ). |
boolean |
removePoint
Set to true to remove the radix point if this is
the last character in the converted string. |
char |
thousand
The character used as the thousands separator. |
Constructor Summary | |
---|---|
Real.NumberFormat()
|
Method Summary |
---|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int base
Real.and()
for an explanation of the interpretation of a
Real
in base 2, 8 and 16.
Negative numbers output in base-2, base-8 and base-16 are
shown in two's complement form. This form guarantees that a
negative number starts with at least one digit that is the
maximum digit for that base, i.e. '1', '7', and 'F',
respectively. A positive number is guaranteed to start with at
least one '0'. Both positive and negative numbers are extended
to the left using this digit, until maxwidth
is
reached.
public int maxwidth
Real
with a given precision
would produce a string wider than
maxwidth
, precision
is reduced until
the number fits within the given width. If
maxwidth
is too small to hold the number with its
sign, exponent and a precision
of 1 digit, the
string may become wider than maxwidth
.
If align
is set to anything but
ALIGN_NONE
and the converted string is shorter
than maxwidth
, the resulting string is padded with
spaces to the specified width according to the alignment.
public int precision
fse
). The default value is 16,
valid values are 0-16 for base-10 and base-16 conversion, 0-21
for base-8 conversion, and 0-63 for base-2 conversion.
The precision
may be reduced to make the number
fit within maxwidth
. The precision
is
also reduced if it is set higher than the actual numbers of
significant digits in a Real
. When
fse
is set to FSE_NONE
, i.e. "normal"
output, the precision is always at maximum, but trailing zeros
are removed.
public int fse
FSE_NONE
. Valid options are listed below.
Numbers are output in one of two main forms, according to
this setting. The normal form has an optional sign, one or more
digits before the radix point, and zero or more digits after the
radix point, for example like this:
3.14159
The exponent form is like the normal form, followed by an
exponent marker 'e', an optional sign and one or more exponent
digits, for example like this:
-3.4753e-13
FSE_NONE
maxwidth
without the exponent form.
FSE_FIX
precision
. Trailing zeros are not removed.
FSE_SCI
precision
. Trailing zeros are not removed.
FSE_ENG
public char point
'.'
. Theoretcally any character that does not
otherwise occur in the output can be used, such as
','
.
Note that setting this to anything but '.'
and
','
is not supported by any conversion method from
String
back to Real
.
public boolean removePoint
true
to remove the radix point if this is
the last character in the converted string. This is the
default.
public char thousand
0
, which disables
thousands-separation. Theoretcally any character that does not
otherwise occur in the output can be used, such as
','
or ' '
.
When thousand!=0
, this character is inserted
between every 3rd digit to the left of the radix point in
base-10 conversion. In base-16 conversion, the separator is
inserted between every 4th digit, and in base-2 conversion the
separator is inserted between every 8th digit. In base-8
conversion, no separator is ever inserted.
Note that tousands separators are not supported by any
conversion method from String
back to
Real
, so use of a thousands separator is meant
only for the presentation of numbers.
public int align
maxwidth
characters. The default value is
ALIGN_NONE
. Valid options are defined as follows:
ALIGN_NONE
ALIGN_LEFT
maxwidth
is reached, making the
number left-aligned within the field.
ALIGN_RIGHT
maxwidth
is reached, making the
number right-aligned within the field.
ALIGN_CENTER
maxwidth
is reached, making the
number center-aligned within the field.
public static final int FSE_NONE
public static final int FSE_FIX
public static final int FSE_SCI
public static final int FSE_ENG
public static final int ALIGN_NONE
public static final int ALIGN_LEFT
public static final int ALIGN_RIGHT
public static final int ALIGN_CENTER
Constructor Detail |
---|
public Real.NumberFormat()
|
Real.java v1.13 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |