php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9834 Unable to handle double variables
Submitted: 2001-03-19 06:11 UTC Modified: 2001-04-19 09:33 UTC
From: jan dot wurl at prosales-europe dot com Assigned:
Status: Closed Package: Math related
PHP Version: 4.0.4pl1 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-03-19 06:11 UTC] jan dot wurl at prosales-europe dot com
I try to set a variable with a double value:

$a=2.54;
$b="2.54"

but PHP ignores everything after the point

echo ($a*100) results 200
echo ($b*100) results 200

I tried everything, i thought it might be work (like setting datatype before set the value, ...), but nothing worked.

Jan Wurl

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-19 11:49 UTC] sniper@php.net
Works for me just fine. But I think it's some locale
thingie. You might have ',' as the decimal separator.
Try setting the locale correctly:

setlocale(LC_NUMERIC, "en_US"); 

or something like that. Or you ',' as the separator.

--Jani

 [2001-04-19 09:33 UTC] sniper@php.net
No feedback.

--Jani

 [2004-08-04 00:52 UTC] robin dot avery at nospamforme dot com
try this:

$a=2\.54;
$b="2\.54"

the forward slashes show that "." is not special.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 18 07:01:30 2024 UTC