Java Code Examples for sun.misc.FloatingDecimal#toJavaFormatString()

The following examples show how to use sun.misc.FloatingDecimal#toJavaFormatString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Double.java    From JDKSourceCode1.8 with MIT License 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 2
Source File: Float.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 3
Source File: Double.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 4
Source File: Float.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 5
Source File: Double.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 6
Source File: Float.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 7
Source File: Double.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 8
Source File: Float.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 9
Source File: Double.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 10
Source File: Float.java    From JDKSourceCode1.8 with MIT License 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 11
Source File: Double.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 12
Source File: Float.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 13
Source File: Double.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 14
Source File: Float.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 15
Source File: Double.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 16
Source File: Float.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 17
Source File: Double.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 18
Source File: Float.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}
 
Example 19
Source File: Double.java    From AndroidComponentPlugin with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code double}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 *     "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 * magnitude (absolute value) of the argument. If the sign is negative,
 * the first character of the result is '{@code -}'
 * ({@code '\u005Cu002D'}); if the sign is positive, no sign character
 * appears in the result. As for the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 * {@code "Infinity"}; thus, positive infinity produces the result
 * {@code "Infinity"} and negative infinity produces the result
 * {@code "-Infinity"}.
 *
 * <li>If <i>m</i> is zero, it is represented by the characters
 * {@code "0.0"}; thus, negative zero produces the result
 * {@code "-0.0"} and positive zero produces the result
 * {@code "0.0"}.
 *
 * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
 * than 10<sup>7</sup>, then it is represented as the integer part of
 * <i>m</i>, in decimal form with no leading zeroes, followed by
 * '{@code .}' ({@code '\u005Cu002E'}), followed by one or
 * more decimal digits representing the fractional part of <i>m</i>.
 *
 * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 * equal to 10<sup>7</sup>, then it is represented in so-called
 * "computerized scientific notation." Let <i>n</i> be the unique
 * integer such that 10<sup><i>n</i></sup> &le; <i>m</i> {@literal <}
 * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
 * mathematically exact quotient of <i>m</i> and
 * 10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10. The
 * magnitude is then represented as the integer part of <i>a</i>,
 * as a single decimal digit, followed by '{@code .}'
 * ({@code '\u005Cu002E'}), followed by decimal digits
 * representing the fractional part of <i>a</i>, followed by the
 * letter '{@code E}' ({@code '\u005Cu0045'}), followed
 * by a representation of <i>n</i> as a decimal integer, as
 * produced by the method {@link Integer#toString(int)}.
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit to represent
 * the fractional part, and beyond that as many, but only as many, more
 * digits as are needed to uniquely distinguish the argument value from
 * adjacent values of type {@code double}. That is, suppose that
 * <i>x</i> is the exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero argument
 * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
 * to <i>x</i>; or if two {@code double} values are equally close
 * to <i>x</i>, then <i>d</i> must be one of them and the least
 * significant bit of the significand of <i>d</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   d   the {@code double} to be converted.
 * @return a string representation of the argument.
 */
public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
}
 
Example 20
Source File: Float.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a string representation of the {@code float}
 * argument. All characters mentioned below are ASCII characters.
 * <ul>
 * <li>If the argument is NaN, the result is the string
 * "{@code NaN}".
 * <li>Otherwise, the result is a string that represents the sign and
 *     magnitude (absolute value) of the argument. If the sign is
 *     negative, the first character of the result is
 *     '{@code -}' ({@code '\u005Cu002D'}); if the sign is
 *     positive, no sign character appears in the result. As for
 *     the magnitude <i>m</i>:
 * <ul>
 * <li>If <i>m</i> is infinity, it is represented by the characters
 *     {@code "Infinity"}; thus, positive infinity produces
 *     the result {@code "Infinity"} and negative infinity
 *     produces the result {@code "-Infinity"}.
 * <li>If <i>m</i> is zero, it is represented by the characters
 *     {@code "0.0"}; thus, negative zero produces the result
 *     {@code "-0.0"} and positive zero produces the result
 *     {@code "0.0"}.
 * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
 *      less than 10<sup>7</sup>, then it is represented as the
 *      integer part of <i>m</i>, in decimal form with no leading
 *      zeroes, followed by '{@code .}'
 *      ({@code '\u005Cu002E'}), followed by one or more
 *      decimal digits representing the fractional part of
 *      <i>m</i>.
 * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
 *      equal to 10<sup>7</sup>, then it is represented in
 *      so-called "computerized scientific notation." Let <i>n</i>
 *      be the unique integer such that 10<sup><i>n</i> </sup>&le;
 *      <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
 *      be the mathematically exact quotient of <i>m</i> and
 *      10<sup><i>n</i></sup> so that 1 &le; <i>a</i> {@literal <} 10.
 *      The magnitude is then represented as the integer part of
 *      <i>a</i>, as a single decimal digit, followed by
 *      '{@code .}' ({@code '\u005Cu002E'}), followed by
 *      decimal digits representing the fractional part of
 *      <i>a</i>, followed by the letter '{@code E}'
 *      ({@code '\u005Cu0045'}), followed by a representation
 *      of <i>n</i> as a decimal integer, as produced by the
 *      method {@link java.lang.Integer#toString(int)}.
 *
 * </ul>
 * </ul>
 * How many digits must be printed for the fractional part of
 * <i>m</i> or <i>a</i>? There must be at least one digit
 * to represent the fractional part, and beyond that as many, but
 * only as many, more digits as are needed to uniquely distinguish
 * the argument value from adjacent values of type
 * {@code float}. That is, suppose that <i>x</i> is the
 * exact mathematical value represented by the decimal
 * representation produced by this method for a finite nonzero
 * argument <i>f</i>. Then <i>f</i> must be the {@code float}
 * value nearest to <i>x</i>; or, if two {@code float} values are
 * equally close to <i>x</i>, then <i>f</i> must be one of
 * them and the least significant bit of the significand of
 * <i>f</i> must be {@code 0}.
 *
 * <p>To create localized string representations of a floating-point
 * value, use subclasses of {@link java.text.NumberFormat}.
 *
 * @param   f   the float to be converted.
 * @return a string representation of the argument.
 */
public static String toString(float f) {
    return FloatingDecimal.toJavaFormatString(f);
}