Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why doesnt Double.infinite return true for infinite fractions?

Tags:

java

double

Double.isInfinite(1.0 / 0.0);

returns true.

Double.isInfinite(1.0 / 3.0);

but this doesnt, and to my understanding this would be an infinite number as this returns 0.33333_ to infinity.

why?

like image 488
Eduardo Dennis Avatar asked Dec 08 '22 07:12

Eduardo Dennis


1 Answers

Double.isInfinite does not return true if the value is infinitely long; it returns true if the value is itself infinite (either positive or negative).

Also, 1.0/3.0 is infinitely long in base 10, but not in other bases, like base 3.

like image 119
Louis Wasserman Avatar answered Dec 10 '22 21:12

Louis Wasserman