Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum float value in php

Is there a way to programmatically retrieve the maximum float value for php. Akin to FLT_MAX or std::numeric_limits< float >::max() in C / C++?

I am using something like the following:

$minimumCost = MAXIMUM_FLOAT_VALUE??;

foreach ( $objects as $object )
{
    $cost = $object->CalculateCost();
    if ( $cost < $minimumCost )
    {
        $minimumCost = $cost;
    }
}

(using php 5.2)

like image 917
Alex Deem Avatar asked Apr 16 '10 03:04

Alex Deem


1 Answers

The float maximum is platform-dependant, and even though it could be useful to get it, there seems to be no (simple) way to get it. You can however use the INF (infinite) constant, which will be bigger than any other value you can ever put in a numeric type, if the goal is only to have a huge placeholder value.

like image 129
zneak Avatar answered Sep 19 '22 00:09

zneak