help : getting float max

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Afternoon all,

This is a quick survey, think it would be useful to have the values of MAX_FLOAT for each platform, and indeed see if it does differ.

to do this can you please run the following code (bc* required) and reply back with the output (and your platform / php version)

code:
<?php

function getMaxFloat() {
	$value = '1';
	$multiplier = '1';
	while(1) {
		$value = bcadd( $value , $multiplier );
		if( (float)$value == INF ) {
			$value = $oldvalue;
			$multiplier = '1';
		} elseif( ((float)bcadd( $value , '10' )) == INF ) {
			while(1) {
				$value = bcadd( $value , '1' );
				if( (float)$value == INF ) {
					return $oldvalue;	
				}
				$oldvalue = $value;
			}
		}
		$oldvalue = $value;
		$multiplier = bcmul( $multiplier , '10' );
	}
}

define( 'FLOAT_MAX' , getMaxFloat() );

echo FLOAT_MAX . PHP_EOL;

?>

my results:

Win Vista 32 bit on Intel Quad Core Duo - PHP 5.2.8
179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791

Thanks!



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux