KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > lang > Float

java.lang
Class Float

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Float
All Implemented Interfaces:
Serializable, Comparable<Float>
See Also:
Top Examples, Source Code

public byte byteValue()
See Also:
Number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static int compare(float f1,
                          float f2)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int compareTo(Float anotherFloat)
See Also:
Comparable.compareTo(Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1011]Float operation
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:58:34  Rate
Float f1 = new Float (  1  ) ; 
 Float f2 = new Float (  1  ) ; 
 Float f3 = new Float (  2  ) ; 
 Float f4 = new Float (  -2  ) ; 
  
  
 if (  f1.compareTo (  f2  )  == 0  )  
     System.out.println ( "Equal" ) ; 
 else {  
     System.out.println ( "Not Equal" ) ; 
     if (  f1.compareTo (  f2  )  == 1  )  
         System.out.println ( "f1 greater than f2" ) ; 
     else System.out.println ( "f1 less than f2" ) ; 
  }  
  
  
 if (  f1.compareTo (  f3  )  == 0 )  
     System.out.println ( "Equal" ) ; 
 else {  
     System.out.println ( "Not Equal" ) ; 
    if (  f1.compareTo (  f3  )  == 1  )  
         System.out.println ( " f1 greater than f3" ) ; 
     else System.out.println ( " f1 less than f3" ) ; 
  }  
  
  
 if (  f1.compareTo (  f4  )  == 0 )  
     System.out.println ( "Equal" ) ; 
 else {  
     System.out.println ( "Not Equal" ) ; 
    if (  f1.compareTo (  f4  )  == 1  )  
         System.out.println ( " f1 greater than f4" ) ; 
     else System.out.println ( " f1 less than f4" ) ; 
  }  
 //outputs the lines: 
 // Equal 
 // Not Equal 
 // f1 less than f3 
 // Not Equal 
 // f1 greater than f4 
  
  
 


public int compareTo(Object o)
See Also:
Comparable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public double doubleValue()
See Also:
Number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1001]Convert string to a float
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:45:40  Rate
String s = "9"; 
 Float f1 = new Double (  s  ) ; 
 double d = f1.doubleValue (  ) ; 
 System.out.println (  d  ) ; 
  
  
 //outputs the line: 
 // 9.0 
 


public boolean equals(Object obj)
See Also:
floatToIntBits(float)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Float(double value)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1004]Convert double to a float
By Jesse L { dot } Jackson - -parisjackson { at } yahoo { dot } com on 2004/10/03 11:50:36  Rate
double d = 23; 
 Float f1 = new Float (  d  ) ; 
  
  
 System.out.println (  f1.floatValue (  )   ) ; 
  
  
 //outputs the line: 
 // 23.0 
 


public Float(float value)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1003]_
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:49:11  Rate
float f = 23; 
 Float f1 = new Float (  f  ) ; 
  
  
 System.out.println (  f1.floatValue (  )   ) ; 
  
  
 //outputs the line: 
 // 23.0 
 


public Float(String s)
      throws NumberFormatException
See Also:
valueOf(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1005]_
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:51:11  Rate
String s = "9"; 
 Float f1 = new Float (  s  ) ; 
 float f = f1.floatValue (  ) ; 
 System.out.println (  f  ) ; 
  
  
 //outputs the line: 
 // 9.0 
 


public static int floatToIntBits(float value)
See Also:
intBitsToFloat(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static int floatToRawIntBits(float value)
See Also:
intBitsToFloat(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public float floatValue()
See Also:
Number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1002]_
By Jesse L { dot } Jackson on 2004/10/03 11:46:52  Rate
String s = "9"; 
 Float f1 = new Float (  s  ) ; 
 float f = f1.floatValue (  ) ; 
 System.out.println (  f  ) ; 
  
  
 //outputs the line: 
 // 9.0 
 


public int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object), floatToIntBits(float)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static float intBitsToFloat(int bits)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int intValue()
See Also:
Number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1834]convert float to int
By Kristen Bains on 2006/10/22 14:18:04  Rate
float val = 3.14; 
 Float fval = new Float ( val ) ; 
 int ival = fval.intValue (  ) ; 
 System.out.println ( "val is " + val + " int is " + ival ) ; 
 


public boolean isInfinite()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static boolean isInfinite(float v)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isNaN()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[26]If we can not calculate an average we will return zero
By Max Okist on 2002/08/07 23:25:53  Rate
Double d = new Double (  sum / count  ) ; 
          
 // If we can't calculate an average we will return zero. 
 if  ( d == null || d.isNaN (  )  )   {  
    d = new Double ( 0.0 ) ; 
  } 


[1806]check the value of the textbox
By shamshir_alam { at } rediffmail { dot } com on 2006/08/17 00:43:45  Rate
i want to check the value of the text box is number or not

public static boolean isNaN(float v)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public long longValue()
See Also:
Number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final float MAX_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1009]Get Float max value
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:56:21  Rate
float f = Float.MAX_VALUE; 
 System.out.println (  f  ) ; 
  
  
 //outputs the line 
 // 3.4028235E38 
 // 
 //MAX_VALUE is a constant - it is the highest value that a float or  
 // the floatValue of an Float can have 
 


public static final float MIN_VALUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1010]Get Float min value
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:57:28  Rate
float f = Float.MIN_VALUE; 
 System.out.println (  f  ) ; 
  
  
 //outputs the line 
 // 1.4E-45 
 


public static final float NaN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final float NEGATIVE_INFINITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static float parseFloat(String s)
                        throws NumberFormatException
See Also:
valueOf(String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[452]Parse a string to a float
By roe { at } ninje { dot } com on 2003/10/11 20:36:48  Rate
try 
      {  
       float rate = Float.parseFloat ( myField.getText (  )  ) ; 
      }  
     catch  ( NumberFormatException ex )  
      {  
       msgs.setText ( "Error- invalid user input. " + ex ) ; 
      } 


[621]_
By Anonymous on 2004/01/22 09:59:39  Rate
Float theFloat = new Float ( parseFloat ( floatString )  ) ;

public static final float POSITIVE_INFINITY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public short shortValue()
See Also:
Number
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int SIZE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static String toHexString(float f)
See Also:
Integer.toString
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
toString(float), Object
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1006]Convert float to string
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:52:26  Rate
Float f1 = new Float (  100  ) ; 
 String s = f1.toString (  ) ; 
  
  
 System.out.println (  s  ) ; 
  
  
 //outputs the line: 
 // 100.0 
 


public static String toString(float f)
See Also:
NumberFormat, Integer.toString(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1007]_
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:53:05  Rate
System.out.println (  Float.toString (  50.5  )   ) ; 
  
  
 //outputs the line: 
 // 50.5 
 


public static final Class<Float> TYPE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static Float valueOf(float f)
See Also:
Float(float)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static Float valueOf(String s)
                     throws NumberFormatException
See Also:
NumberFormat, String.trim()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1008]_
By Jesse L { dot } Jackson - parisjackson { at } yahoo { dot } com on 2004/10/03 11:54:16  Rate
String s = "14.5"; 
 Float f1 = Float.valueOf (  s  ) ; 
 System.out.println (  f1.toString (  )   ) ; 
  
  
 //outputs the line 
 // 14.5 
 

Popular Tags