< prev index next >

src/java.base/share/classes/jdk/internal/math/FloatingDecimal.java

Print this page

 966                     result[i++] = (char) (e / 100 + '0');
 967                     e %= 100;
 968                     result[i++] = (char) (e / 10 + '0');
 969                     result[i++] = (char) (e % 10 + '0');
 970                 }
 971             }
 972             return i;
 973         }
 974 
 975     }
 976 
 977     private static final ThreadLocal<BinaryToASCIIBuffer> threadLocalBinaryToASCIIBuffer =
 978             new ThreadLocal<BinaryToASCIIBuffer>() {
 979                 @Override
 980                 protected BinaryToASCIIBuffer initialValue() {
 981                     return new BinaryToASCIIBuffer();
 982                 }
 983             };
 984 
 985     private static BinaryToASCIIBuffer getBinaryToASCIIBuffer() {
 986         return threadLocalBinaryToASCIIBuffer.get();




 987     }
 988 
 989     /**
 990      * A converter which can process an ASCII <code>String</code> representation
 991      * of a single or double precision floating point value into a
 992      * <code>float</code> or a <code>double</code>.
 993      */
 994     interface ASCIIToBinaryConverter {
 995 
 996         double doubleValue();
 997 
 998         float floatValue();
 999 
1000     }
1001 
1002     /**
1003      * A <code>ASCIIToBinaryConverter</code> container for a <code>double</code>.
1004      */
1005     static class PreparedASCIIToBinaryBuffer implements ASCIIToBinaryConverter {
1006         private final double doubleVal;

 966                     result[i++] = (char) (e / 100 + '0');
 967                     e %= 100;
 968                     result[i++] = (char) (e / 10 + '0');
 969                     result[i++] = (char) (e % 10 + '0');
 970                 }
 971             }
 972             return i;
 973         }
 974 
 975     }
 976 
 977     private static final ThreadLocal<BinaryToASCIIBuffer> threadLocalBinaryToASCIIBuffer =
 978             new ThreadLocal<BinaryToASCIIBuffer>() {
 979                 @Override
 980                 protected BinaryToASCIIBuffer initialValue() {
 981                     return new BinaryToASCIIBuffer();
 982                 }
 983             };
 984 
 985     private static BinaryToASCIIBuffer getBinaryToASCIIBuffer() {
 986         if (Thread.currentThread().isVirtual()) {
 987             return new BinaryToASCIIBuffer();
 988         } else {
 989             return threadLocalBinaryToASCIIBuffer.get();
 990         }
 991     }
 992 
 993     /**
 994      * A converter which can process an ASCII <code>String</code> representation
 995      * of a single or double precision floating point value into a
 996      * <code>float</code> or a <code>double</code>.
 997      */
 998     interface ASCIIToBinaryConverter {
 999 
1000         double doubleValue();
1001 
1002         float floatValue();
1003 
1004     }
1005 
1006     /**
1007      * A <code>ASCIIToBinaryConverter</code> container for a <code>double</code>.
1008      */
1009     static class PreparedASCIIToBinaryBuffer implements ASCIIToBinaryConverter {
1010         private final double doubleVal;
< prev index next >