Doc #77674 [Opn->Nab]: Range function doesn't include

From: Date: Wed, 27 Feb 2019 11:31:47 +0000
Subject: Doc #77674 [Opn->Nab]: Range function doesn't include
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16433@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77674&edit=1 ID: 77674 Updated by: cmb@php.net Reported by: lifekent at gmail dot com Summary: Range function doesn't include -Status: Open +Status: Not a bug Type: Documentation Problem Package: Documentation problem Operating System: Linux PHP Version: 7.2.15 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Floating point values have a limited precision. Hence a value might not have the same string representation after any processing. That also includes writing a floating point value in your script and directly printing it without any mathematical operations. If you would like to know more about "floats" and what IEEE 754 is, read this: http://www.floating-point-gui.de/ Thank you for your interest in PHP. See also <https://github.com/php/php-src/pull/2804>. Previous Comments: ------------------------------------------------------------------------ [2019-02-27 10:28:23] lifekent at gmail dot com Description: ------------ --- From manual page: https://php.net/function.range --- If this is an intended behavior than it must be in the http://php.net/manual/en/doc.changelog.php Range function description: The sequence is ended upon reaching the end value. This works in PHP 7.0.2 but works different starting from the PHP 7.0.3 and doesn't include the end value. Test script: --------------- $min = 0.2; $max = 5; print_r(range($min, $max, 0.2)); Expected result: ---------------- ( [0] => 0.2 [1] => 0.4 [2] => 0.6 [3] => 0.8 [4] => 1 [5] => 1.2 [6] => 1.4 [7] => 1.6 [8] => 1.8 [9] => 2 [10] => 2.2 [11] => 2.4 [12] => 2.6 [13] => 2.8 [14] => 3 [15] => 3.2 [16] => 3.4 [17] => 3.6 [18] => 3.8 [19] => 4 [20] => 4.2 [21] => 4.4 [22] => 4.6 [23] => 4.8 [24] => 5 ) Actual result: -------------- ( [0] => 0.2 [1] => 0.4 [2] => 0.6 [3] => 0.8 [4] => 1 [5] => 1.2 [6] => 1.4 [7] => 1.6 [8] => 1.8 [9] => 2 [10] => 2.2 [11] => 2.4 [12] => 2.6 [13] => 2.8 [14] => 3 [15] => 3.2 [16] => 3.4 [17] => 3.6 [18] => 3.8 [19] => 4 [20] => 4.2 [21] => 4.4 [22] => 4.6 [23] => 4.8 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77674&edit=1

« previous php.doc.bugs (#16433) next »