php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26713 Detail
Submitted: 2003-12-24 17:46 UTC Modified: 2003-12-24 18:32 UTC
From: turgut85 at hotmail dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: Irrelevant OS: Windows XP
Private report: No CVE-ID: None
 [2003-12-24 17:46 UTC] turgut85 at hotmail dot com
Description:
------------
Is anyone can help me about the code below . Here is I am collecting values according to increment value between number ranges.
My first example never hits the end point although the end is in range but second hits the range or third.
Why php treats numbers differently or cannot understand the last value is still below end point.
Can anyone tell me.



Reproduce code:
---------------
<?PHP
function increment ($start, $end, $increment_val)
{	
	$ret_arry = array ();	
		
	$temp = $start;	
		
		if ( ($start+$increment_val) <= $end )
		{
			do{
					
			        echo " " . $temp . "," ;
			        $temp = $temp + $increment_val;
			        
			 }while ( $temp <= $end );
		}
		else
		{
		echo "Can not do This";
		}
		
		
}

$start = "1.0";
$end = "1.6";
$increment_val = "0.1"; 

increment($start, $end, $increment_val);

$start = "1.0";
$end = "4.9";
$increment_val = "0.1"; 

echo "\n";
increment($start, $end, $increment_val);
?>


Expected result:
----------------
1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6
1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9,

Actual result:
--------------
1.0, 1.1, 1.2, 1.3, 1.4, 1.5,
1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9,

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-24 18:32 UTC] eru@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 16:01:23 2019 UTC