Bug #72017 [Opn]: range() with float step produces unexpected result

From: Date: Wed, 13 Apr 2016 16:44:33 +0000
Subject: Bug #72017 [Opn]: range() with float step produces unexpected result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200530@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72017&edit=1

 ID:                 72017
 Updated by:         pollita@php.net
 Reported by:        contact at rarst dot net
 Summary:            range() with float step produces unexpected result
 Status:             Open
 Type:               Bug
 Package:            Arrays related
 Operating System:   Windows 7 x64
 PHP Version:        7.0.5
-Assigned To:        
+Assigned To:        tpunt
 Block user comment: N
 Private report:     N

 New Comment:

Looks to be caused by https://github.com/php/php-src/pull/1695

https://github.com/php/php-src/commit/3bbcd84e2fd96ec15df21b87aed534a0434a151e


Previous Comments:
------------------------------------------------------------------------
[2016-04-13 16:15:16] contact at rarst dot net

Description:
------------
Running this call range( 4.5, 4.2, 0.1 ) with these specific numbers (discovered
empirically, other ranges might not demonstrate the issue).

I expect result to be: array(4) 4.5, 4.4, 4.3, 4.2

I observe result to be: array(3) 4.5, 4.4, 4.3

I've run this in online checker and it reported expected result up to version 7.0.2 and
unexpected result starting from 7.0.3, see https://3v4l.org/BbS2k

Test script:
---------------
var_dump( range( 4.5, 4.2, 0.1 ) );

Expected result:
----------------
array(4) {
  [0]=>
  float(4.5)
  [1]=>
  float(4.4)
  [2]=>
  float(4.3)
  [3]=>
  float(4.2)
}

Actual result:
--------------
array(3) {
  [0]=>
  float(4.5)
  [1]=>
  float(4.4)
  [2]=>
  float(4.3)
}


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72017&edit=1


Thread (3 messages)

« previous php.bugs (#200530) next »