public class SimpleDecimaliser extends Object implements Decimaliser
Decimaliser using simple rounding.
It attempts to represent numbers with up to LARGEST_EXPONENT_IN_LONG
decimal places. If the scaled mantissa exceeds MANTISSA_LIMIT the
method gives up and returns false.
This approach is optimised for speed and is thread-safe.
See MaximumPrecision for a more accurate alternative.
| Modifier and Type | Field and Description |
|---|---|
static int |
LARGEST_EXPONENT_IN_LONG
The largest exponent that can be represented using a long integer.
|
static Decimaliser |
SIMPLE
A singleton instance of
SimpleDecimaliser for convenient reuse. |
| Constructor and Description |
|---|
SimpleDecimaliser() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
toDecimal(double value,
DecimalAppender decimalAppender)
Convert
value using a simple rounding approach and append the result. |
boolean |
toDecimal(float value,
DecimalAppender decimalAppender)
Convert
value using a simple rounding approach and append the result. |
public static final int LARGEST_EXPONENT_IN_LONG
public static final Decimaliser SIMPLE
SimpleDecimaliser for convenient reuse.
This instance is thread-safe and can be used across multiple threads without synchronization.public boolean toDecimal(double value,
DecimalAppender decimalAppender)
value using a simple rounding approach and append the result.
This method iteratively scales the input value by powers of 10, and performs rounding to attempt finding a precise
representation. If such representation is found, it is appended using the provided DecimalAppender.
toDecimal in interface Decimaliservalue - the double value to convert; must be finitedecimalAppender - the appender that receives sign, mantissa and exponenttrue if the value was represented within MANTISSA_LIMIT
and LARGEST_EXPONENT_IN_LONGpublic boolean toDecimal(float value,
DecimalAppender decimalAppender)
value using a simple rounding approach and append the result.toDecimal in interface Decimaliservalue - the float value to convert; must be finitedecimalAppender - the appender that receives sign, mantissa and exponenttrue if the value was represented within LARGEST_EXPONENT_IN_LONGCopyright © 2026 Chronicle Software Ltd. All rights reserved.