Bug #73864 [Com]: '3.' is considered as a numeric string

From: Date: Sat, 07 Jan 2017 06:39:00 +0000
Subject: Bug #73864 [Com]: '3.' is considered as a numeric string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206345@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73864&edit=1 ID: 73864 Comment by: a at b dot c dot de Reported by: mumu at seznam dot cz Summary: '3.' is considered as a numeric string Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Windows 10 PHP Version: 7.1.0 Assigned To: cmb Block user comment: N Private report: N New Comment: A real-world example of "3." results from measuring the circumference and diameter of a circle to one significant digit and taking their ratio (cf. I Kings 7:23). Previous Comments: ------------------------------------------------------------------------ [2017-01-06 17:51:19] cmb@php.net > (has no match in real world) Well, floating point numbers generally do not match the real world. Anyhow, the valid syntax of float numbers is well documented[1], so this is not a bug. [1] <http://php.net/manual/en/language.types.float.php> ------------------------------------------------------------------------ [2017-01-06 10:43:55] mumu at seznam dot cz I would not expect 3. to be a valid syntax of a number. However, it seems to be valid notation in PHP. Personally, I would be happy if this syntax is not a valid number as it is quite confusing and weird (has no match in real world). ------------------------------------------------------------------------ [2017-01-04 21:48:38] requinix@php.net It is a valid number. Why shouldn't it be? ------------------------------------------------------------------------ [2017-01-04 21:44:17] mumu at seznam dot cz Description: ------------ '3.' is evaluated as a numeric string even it is not a valid number. Test script: --------------- <?php echo '3. ' . (is_numeric('3.') ? 'IS' : 'IS NOT') . ' numeric'; ?> Expected result: ---------------- is_numeric('3.') returns false. Actual result: -------------- is_numeric('3.') returns true. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73864&edit=1

« previous php.bugs (#206345) next »