< prev index next >

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

Print this page
rev 55787 : 8228507: Archive FDBigInteger
Reviewed-by: TBD

*** 129,187 **** public interface BinaryToASCIIConverter { /** * Converts a floating point value into an ASCII <code>String</code>. * @return The value converted to a <code>String</code>. */ ! public String toJavaFormatString(); /** * Appends a floating point value to an <code>Appendable</code>. * @param buf The <code>Appendable</code> to receive the value. */ ! public void appendTo(Appendable buf); /** * Retrieves the decimal exponent most closely corresponding to this value. * @return The decimal exponent. */ ! public int getDecimalExponent(); /** * Retrieves the value as an array of digits. * @param digits The digit array. * @return The number of valid digits copied into the array. */ ! public int getDigits(char[] digits); /** * Indicates the sign of the value. * @return {@code value < 0.0}. */ ! public boolean isNegative(); /** * Indicates whether the value is either infinite or not a number. * * @return <code>true</code> if and only if the value is <code>NaN</code> * or infinite. */ ! public boolean isExceptional(); /** * Indicates whether the value was rounded up during the binary to ASCII * conversion. * * @return <code>true</code> if and only if the value was rounded up. */ ! public boolean digitsRoundedUp(); /** * Indicates whether the binary to ASCII conversion was exact. * * @return <code>true</code> if any only if the conversion was exact. */ ! public boolean decimalDigitsExact(); } /** * A <code>BinaryToASCIIConverter</code> which represents <code>NaN</code> * and infinite values. --- 129,187 ---- public interface BinaryToASCIIConverter { /** * Converts a floating point value into an ASCII <code>String</code>. * @return The value converted to a <code>String</code>. */ ! String toJavaFormatString(); /** * Appends a floating point value to an <code>Appendable</code>. * @param buf The <code>Appendable</code> to receive the value. */ ! void appendTo(Appendable buf); /** * Retrieves the decimal exponent most closely corresponding to this value. * @return The decimal exponent. */ ! int getDecimalExponent(); /** * Retrieves the value as an array of digits. * @param digits The digit array. * @return The number of valid digits copied into the array. */ ! int getDigits(char[] digits); /** * Indicates the sign of the value. * @return {@code value < 0.0}. */ ! boolean isNegative(); /** * Indicates whether the value is either infinite or not a number. * * @return <code>true</code> if and only if the value is <code>NaN</code> * or infinite. */ ! boolean isExceptional(); /** * Indicates whether the value was rounded up during the binary to ASCII * conversion. * * @return <code>true</code> if and only if the value was rounded up. */ ! boolean digitsRoundedUp(); /** * Indicates whether the binary to ASCII conversion was exact. * * @return <code>true</code> if any only if the conversion was exact. */ ! boolean decimalDigitsExact(); } /** * A <code>BinaryToASCIIConverter</code> which represents <code>NaN</code> * and infinite values.
*** 319,329 **** return decExponent; } @Override public int getDigits(char[] digits) { ! System.arraycopy(this.digits,firstDigitIndex,digits,0,this.nDigits); return this.nDigits; } @Override public boolean isNegative() { --- 319,329 ---- return decExponent; } @Override public int getDigits(char[] digits) { ! System.arraycopy(this.digits, firstDigitIndex, digits, 0, this.nDigits); return this.nDigits; } @Override public boolean isNegative() {
*** 847,857 **** * <pre> * insignificantDigitsForPow2(v) == insignificantDigits(1L<<v) * </pre> */ private static int insignificantDigitsForPow2(int p2) { ! if(p2>1 && p2 < insignificantDigitsNumber.length) { return insignificantDigitsNumber[p2]; } return 0; } --- 847,857 ---- * <pre> * insignificantDigitsForPow2(v) == insignificantDigits(1L<<v) * </pre> */ private static int insignificantDigitsForPow2(int p2) { ! if (p2 > 1 && p2 < insignificantDigitsNumber.length) { return insignificantDigitsNumber[p2]; } return 0; }
*** 860,870 **** * i = insignificantDigitsNumber[idx] is the same as: * int i; * for ( i = 0; insignificant >= 10L; i++ ) * insignificant /= 10L; */ ! private static int[] insignificantDigitsNumber = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 17, 17, 17, --- 860,870 ---- * i = insignificantDigitsNumber[idx] is the same as: * int i; * for ( i = 0; insignificant >= 10L; i++ ) * insignificant /= 10L; */ ! private static final int[] insignificantDigitsNumber = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 17, 17, 17,
*** 1871,1885 **** } } } // look for and process decimal floating-point string char[] digits = new char[ len ]; - int nDigits= 0; boolean decSeen = false; int decPt = 0; int nLeadZero = 0; ! int nTrailZero= 0; skipLeadingZerosLoop: while (i < len) { c = in.charAt(i); if (c == '0') { --- 1871,1885 ---- } } } // look for and process decimal floating-point string char[] digits = new char[ len ]; boolean decSeen = false; + int nDigits = 0; int decPt = 0; int nLeadZero = 0; ! int nTrailZero = 0; skipLeadingZerosLoop: while (i < len) { c = in.charAt(i); if (c == '0') {
*** 2135,2147 **** // // If the significand is exactly zero, return a properly // signed zero. // ! String significandString = null; ! int signifLength = 0; ! int exponentAdjust = 0; { int leftDigits = 0; // number of meaningful digits to // left of "decimal" point // (leading zeros stripped) int rightDigits = 0; // number of digits to right of --- 2135,2147 ---- // // If the significand is exactly zero, return a properly // signed zero. // ! String significandString; ! int signifLength; ! int exponentAdjust; { int leftDigits = 0; // number of meaningful digits to // left of "decimal" point // (leading zeros stripped) int rightDigits = 0; // number of digits to right of
*** 2244,2254 **** // a long; copy explicit bit too; this will be masked // later for normal values. boolean round = false; boolean sticky = false; ! int nextShift = 0; long significand = 0L; // First iteration is different, since we only copy // from the leading significand bit; one more exponent // adjust will be needed... --- 2244,2254 ---- // a long; copy explicit bit too; this will be masked // later for normal values. boolean round = false; boolean sticky = false; ! int nextShift; long significand = 0L; // First iteration is different, since we only copy // from the leading significand bit; one more exponent // adjust will be needed...
*** 2523,2533 **** /** * Returns <code>s</code> with any leading zeros removed. */ static String stripLeadingZeros(String s) { - // return s.replaceFirst("^0+", ""); if(!s.isEmpty() && s.charAt(0)=='0') { for(int i=1; i<s.length(); i++) { if(s.charAt(i)!='0') { return s.substring(i); } --- 2523,2532 ----
< prev index next >