Bug #72017 [Asn->Csd]: range() with float step produces unexpected result

From: Date: Mon, 16 May 2016 21:21:28 +0000
Subject: Bug #72017 [Asn->Csd]: range() with float step produces unexpected result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201142@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:         ab@php.net
 Reported by:        contact at rarst dot net
 Summary:            range() with float step produces unexpected result
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            Arrays related
 Operating System:   Windows 7 x64
 PHP Version:        7.0.5
 Assigned To:        tpunt
 Block user comment: N
 Private report:     N

 New Comment:

Fixed by the PR https://github.com/php/php-src/pull/1863

Thanks.


Previous Comments:
------------------------------------------------------------------------
[2016-04-13 16:44:33] pollita@php.net

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

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

------------------------------------------------------------------------
[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 (#201142) next »