Class CharConversion_double


  • public final class CharConversion_double
    extends Object
    • Constructor Detail

      • CharConversion_double

        public CharConversion_double()
    • Method Detail

      • put

        public static final int put​(double value,
                                    char[] target,
                                    int offset)
        This algorithm is somewhere from 3 times to 25 times (depending on exponent) faster than the infinite spaghetti code used in JDK. It generates discrepancies of +/- 1 at the 16th digit and +/- 8 in the 17th digit compared to the stricter JDK algorithm. As digits 16 and 17 cannot be relied upon anyway due to the technical floating point inaccuracy (e.g. the JDK double parser generates comparable discrepancies), the algorithm is still deemed correct ("enough").

        Otherwise, the behavior of the algorithm is the same as that of the JDK implementation (i.e. decimal point character '.', denormalized representation in range ]1E7; 1E-3], exponent character 'E', etc.

        Note that this method is intended as an implementation detail and a "know-what-you-are-doing" tool that does not perform array bound checks. If array bound checking is desired, use VarString.add(double) explicitly.

        Parameters:
        value - the value to be represented as a character sequence.
        target - the array to receive the character sequence at the given offset.
        offset - the offset in the target array where the character sequence shall start.
        Returns:
        the offset pointing to the index after the last character of the assembled sequence.