src/share/classes/java/lang/Float.java

Print this page




 424      * {@link #Float(float)}, as this method is likely to yield
 425      * significantly better space and time performance by caching
 426      * frequently requested values.
 427      *
 428      * @param  f a float value.
 429      * @return a {@code Float} instance representing {@code f}.
 430      * @since  1.5
 431      */
 432     public static Float valueOf(float f) {
 433         return new Float(f);
 434     }
 435 
 436     /**
 437      * Returns a new {@code float} initialized to the value
 438      * represented by the specified {@code String}, as performed
 439      * by the {@code valueOf} method of class {@code Float}.
 440      *
 441      * @param      s   the string to be parsed.
 442      * @return the {@code float} value represented by the string
 443      *         argument.

 444      * @throws  NumberFormatException  if the string does not contain a
 445      *               parsable {@code float}.
 446      * @see        java.lang.Float#valueOf(String)
 447      * @since 1.2
 448      */
 449     public static float parseFloat(String s) throws NumberFormatException {
 450         return FloatingDecimal.readJavaFormatString(s).floatValue();
 451     }
 452 
 453     /**
 454      * Returns {@code true} if the specified number is a
 455      * Not-a-Number (NaN) value, {@code false} otherwise.
 456      *
 457      * @param   v   the value to be tested.
 458      * @return  {@code true} if the argument is NaN;
 459      *          {@code false} otherwise.
 460      */
 461     static public boolean isNaN(float v) {
 462         return (v != v);
 463     }




 424      * {@link #Float(float)}, as this method is likely to yield
 425      * significantly better space and time performance by caching
 426      * frequently requested values.
 427      *
 428      * @param  f a float value.
 429      * @return a {@code Float} instance representing {@code f}.
 430      * @since  1.5
 431      */
 432     public static Float valueOf(float f) {
 433         return new Float(f);
 434     }
 435 
 436     /**
 437      * Returns a new {@code float} initialized to the value
 438      * represented by the specified {@code String}, as performed
 439      * by the {@code valueOf} method of class {@code Float}.
 440      *
 441      * @param  s the string to be parsed.
 442      * @return the {@code float} value represented by the string
 443      *         argument.
 444      * @throws NullPointerException  if the string is null
 445      * @throws NumberFormatException if the string does not contain a
 446      *               parsable {@code float}.
 447      * @see    java.lang.Float#valueOf(String)
 448      * @since 1.2
 449      */
 450     public static float parseFloat(String s) throws NumberFormatException {
 451         return FloatingDecimal.readJavaFormatString(s).floatValue();
 452     }
 453 
 454     /**
 455      * Returns {@code true} if the specified number is a
 456      * Not-a-Number (NaN) value, {@code false} otherwise.
 457      *
 458      * @param   v   the value to be tested.
 459      * @return  {@code true} if the argument is NaN;
 460      *          {@code false} otherwise.
 461      */
 462     static public boolean isNaN(float v) {
 463         return (v != v);
 464     }