Actually any string ending in INF is more appropriate than any string beginning with INF. Since negative infinity evaluates to "-INF" but it is still infinite. However in either case the STRING "INF" is not infinite, only a float that converts to "INF" or "-INF" is infinite.
A more appropriate function might be:
<?php
if (!is_defined('is_infinite')) { function is_infinite($val) {
return (is_float($val) and ("$val"=='INF' or "$val"=='-INF'));
} }
?>
* However the above function is untested.
is_infinite
(PHP 4 >= 4.2.0, PHP 5)
is_infinite — Indique si un nombre est infini
Description
bool is_infinite
( float $val
)
Retourne TRUE si val est infini (positif ou négatif), comme le résultat de log(0) ou une valeur qui est trop grande pour être représenté par un nombre à virgule flottante sur cette plate-forme.
Liste de paramètres
- val
-
La valeur à vérifier
Valeurs de retour
TRUE si val est une valeur infinie, sinon, FALSE.
is_infinite
stangelanda at arrowquick dot com
28-Aug-2007 04:29
28-Aug-2007 04:29
21-Aug-2006 05:54
@ david,
That will return true for any string ending with "INF".
I think substr("$value",0,3) would be more appropriate.
david(@t)nirvanis(d@t)org
31-Aug-2004 11:49
31-Aug-2004 11:49
If you have PHP lower than 4.2 you can simulate the behaviour:
function is_infinite($value) {
return (substr("$value",-3) == "INF");
}
(tested on php 4.1.2)
