Float byteValue() method in Java with Examples Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.lang.Float.byteValue() is a built-in method in Java that returns the value of this Float as a byte(by casting to a byte). Basically it used for narrowing primitive conversion of Float type to a byte value. Syntax: public byte byteValue() Parameters: The function does not accept any parameter. Return Value: This method returns the Float value represented by this object converted to type byte. Examples: Input : 12 Output : 12 Input : 1023 Output : -1 Below programs illustrates the java.lang.Float.byteValue() function: Program 1: java // Program to illustrate the Float.byteValue() method import java.lang.*; public class GFG { public static void main(String[] args) { Float value = 1023f; // Returns the value of Float as a byte byte byteValue = value.byteValue(); System.out.println("Byte Value of num = " + byteValue); // Another example value = 12f; byteValue = value.byteValue(); System.out.println("Byte Value of num = " + byteValue); } } Output: Byte Value of num = -1 Byte Value of num = 12 Program 2 : Demonstrates the byte value for a negative number. java // Java code to illustrate java.lang.Float.byteValue() method import java.lang.*; public class GFG { public static void main(String[] args) { Float value = -1023f; // Returns the value of Float as a byte byte byteValue = value.byteValue(); System.out.println("Byte Value of num = " + byteValue); // Another example value = -12f; byteValue = value.byteValue(); System.out.println("Byte Value of num = " + byteValue); } } Output: Byte Value of num = 1 Byte Value of num = -12 Program 3 : When a decimal value is passed in argument. java // Program to illustrate java.lang.Float.byteValue() method import java.lang.*; public class GFG { public static void main(String[] args) { Float value = 11.24f; // Returns the value of Float as a byte byte byteValue = value.byteValue(); System.out.println("Byte Value of num = " + byteValue); // Another example value = 6.0f; byteValue = value.byteValue(); System.out.println("Byte Value of num = " + byteValue); } } Output: Byte Value of num = 11 Byte Value of num = 6 Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#byteValue() Comment More infoAdvertise with us Next Article Byte floatValue() method in Java with examples G gopaldave Follow Improve Article Tags : Java Java-lang package Java-Functions Practice Tags : Java Similar Reads Float doubleValue() method in Java with examples The doubleValue() method of Float class is a built in method to return the value specified by the calling object as double after type casting. Syntax: FloatObject.doubleValue() Return Value: It return the double value of this Float object. Below programs illustrate doubleValue() method in Java: Prog 2 min read Float doubleValue() method in Java with examples The doubleValue() method of Float class is a built in method to return the value specified by the calling object as double after type casting. Syntax: FloatObject.doubleValue() Return Value: It return the double value of this Float object. Below programs illustrate doubleValue() method in Java: Prog 2 min read Byte floatValue() method in Java with examples The floatValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as float. Syntax ByteObject.floatValue() Return Value: It return the value of ByteObject as float. Below is the implementation of floatValue() method in Java: Example 1: Java // J 2 min read Byte floatValue() method in Java with examples The floatValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as float. Syntax ByteObject.floatValue() Return Value: It return the value of ByteObject as float. Below is the implementation of floatValue() method in Java: Example 1: Java // J 2 min read Float compare() Method in Java with Examples The compare() method of Float Class is a built-in method in Java that compares the two specified float values. The sign of the integer value returned is the same as that of the integer that would be returned by the function call. Syntax: public static int compare(float f1, float f2)Parameters: The f 2 min read Float compare() Method in Java with Examples The compare() method of Float Class is a built-in method in Java that compares the two specified float values. The sign of the integer value returned is the same as that of the integer that would be returned by the function call. Syntax: public static int compare(float f1, float f2)Parameters: The f 2 min read Like