|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-04-04 14:56 UTC] ehanneken at pobox dot com
Description: ------------ According to the manual (http://www.php.net/manual/en/language.types.float.php), the following grammar specifies floating point numbers: LNUM [0-9]+ DNUM ([0-9]*[\.]{LNUM}) | ({LNUM}[\.][0-9]*) EXPONENT_DNUM ( ({LNUM} | {DNUM}) [eE][+-]? {LNUM}) This leaves out signed numbers. The grammar should be written as something like ULNUM [0-9]+ SLNUM [+-]{ULNUM} DNUM [+-]?(([0-9]*[\.]{ULNUM}) | ({ULNUM}[\.][0-9]*)) EXPONENT_DNUM [+-]?( ({ULNUM} | {DNUM}) [eE][+-]? {ULNUM}) Reproduce code: --------------- echo gettype(-3.14) . "\n"; echo gettype(+3.14); Expected result: ---------------- double double Actual result: -------------- double double PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 19:00:02 2025 UTC |
There was a bug in my revised grammer, too. How about this? ULNUM [0-9]+ SLNUM [+-]{ULNUM} DNUM [+-]?(([0-9]*[\.]{ULNUM}) | ({ULNUM}[\.][0-9]*)) EXPONENT_DNUM ( ({SLNUM} | {DNUM}) [eE][+-]? {ULNUM})There was a bug in my revised grammar, too. How about this? ULNUM [0-9]+ SLNUM [+-]{ULNUM} DNUM [+-]?(([0-9]*[\.]{ULNUM}) | ({ULNUM}[\.][0-9]*)) EXPONENT_DNUM ( ({SLNUM} | {DNUM}) [eE][+-]? {ULNUM})