downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

is_nan> <is_finite
[edit] Last updated: Fri, 18 May 2012

view this page in

is_infinite

(PHP 4 >= 4.2.0, PHP 5)

is_infinitePrüft ob ein Wert unendlich ist

Beschreibung

bool is_infinite ( float $val )

Die Funktion prüft ob ein Wert unendlich, oder besser nicht-endlich ist. Als nicht endlich gelten dabei Ergebnisse von Berechnungen wie log(0) ebenso wie Werte, die schlicht nur zu groß sind, um noch mit dem float Typ der jeweiligen Plattform erfasst zu werden. Es wird dabei nicht zwischen positiv unendlich und negativ unendlich unterschieden.

Parameter-Liste

val

Der zu prüfende Wert

Rückgabewerte

TRUE wenn val nicht endlich ist, sonst FALSE.

Siehe auch

  • is_finite() - Prüft auf einen gültigen endlichen Wert
  • is_nan() - Prüft ob ein Wert keine Zahl ist



is_nan> <is_finite
[edit] Last updated: Fri, 18 May 2012
 
add a note add a note User Contributed Notes is_infinite
Anonymous 02-May-2012 04:55
PHP_INT_MAX is The largest integer supported in this build of PHP. Usually int(2147483647). Available since PHP 4.4.0 and PHP 5.0.5
stangelanda at arrowquick dot com 28-Aug-2007 07:29
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.
21-Aug-2006 08: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 02: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)

 
show source | credits | sitemap | contact | advertising | mirror sites