Home » Java Float isInfinite() method with Examples

Java Float isInfinite() method with Examples

by Online Tutorials Library

Java Float isInfinite() Method

The isInfinite() method of Java Float class returns a Boolean value for the specified float object or for ‘v’. This method returns true if the argument passed is infinitely large in magnitude and returns false for finite floating-point arguments.

The isInfinite() method is vice – versa of ‘isFinite()’ method.

Syntax:

Parameters:

  1. 1.The parameter passed is ‘v’ which is of float type.
  2. NA

Return Value:

This method returns a Boolean value for this float object.

  • Returns true, if the argument passed is positive or negative infinity.
  • Returns false, if the arguments passed is Nan or finite floating-point numbers.

Example 1

Test it Now

Output:

Infinity value for isInfinite() method is : true  Infinity value for isFinite() method is   : false  

Example 2

Test it Now

Output:

1. 2.13909504E9 value = false  2. 7.6E-42 value = false  3. NaN value = false  4. -Infinity value = true  

Example 3

Test it Now

Output:

1. 7.643476E10 value = false  2. 27.827 value = false  3. Infinity value = true  4. -Infinity value = true  5. NaN value = false  

Example 4

Test it Now

Output:

Error:(7, 24) java: float cannot be dereferenced  

Here, float is primitive data type. Its object can’t be used to call Float class methods. If done, so it will give the above described error.

Next TopicJava Float

You may also like