473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Where decimal part goes?

gs
Sorry if it will be second post, but after few hours I still can't see
my previous post.

I have problem with decimal parts on Solaris (PHP+ZendOptimizer). When I
get value from MySQL (or from text file - I have had the same), it is
loosing decimal parts.

For example, let say, that from MySQL I have $line[myvalue]=123.45
Then if I will do this:

echo $line[myvalue];
echo number_format($line[myvalue],2,".","");
echo 1*$line[myvalue];

I will recive this values:

123.45
123.00 => ?????
123

Does anybody know, where is the problem?
On some other instalation (on Windows and Linux) everything is O'K.

What is more interesting, when I compute this value - let say like this:

$newvalue=1.22*$something

I will have $newvalue eqal to 150,06, which is 1.22*123
And I can do everything with it without any problems.

Hope somebody could help me solving this problem,

Grzegorz Sowa
Jul 17 '05 #1
6 1884
gs wrote:
Sorry if it will be second post, but after few hours I still can't see
my previous post.

I have problem with decimal parts on Solaris (PHP+ZendOptimizer). When I
get value from MySQL (or from text file - I have had the same), it is
loosing decimal parts.

For example, let say, that from MySQL I have $line[myvalue]=123.45
Then if I will do this:

echo $line[myvalue];
echo number_format($line[myvalue],2,".","");
echo 1*$line[myvalue];

I will recive this values:

123.45
123.00 => ?????
123

Does anybody know, where is the problem?
On some other instalation (on Windows and Linux) everything is O'K.

What is more interesting, when I compute this value - let say like this:

$newvalue=1.22*$something

I will have $newvalue eqal to 150,06, which is 1.22*123
And I can do everything with it without any problems.

Hope somebody could help me solving this problem,

Grzegorz Sowa


It looks like a bug in the numer_format routine. This works on an
OpenVMS PHP version 4.3.2 as well. In this case, you should go to the
PHP site and find the link to report bugs. You will need to most (if
not all) of the information from the output of phpinfo(). Make sure it
includes the OS version and patch level as well as the php version and
any fixes applied.

$line[myvalue]=123.45;
echo "$line[myvalue]\n";
echo number_format($line[myvalue],2,".","")."\n";
echo "$line[myvalue]\n";
echo 1*$line[myvalue]."\n";
echo "$line[myvalue]\n";

RESULT:

123.45
123.45
123.45
123.45
123.45

and just to make sure:

$line[myvalue]=123.45;
echo "$line[myvalue]\n";
$x = number_format($line[myvalue],2,".","");
echo "$x\n";
echo 1*$line[myvalue]."\n";
echo 1*$x."\n";
echo "$line[myvalue]\n";

123.45
123.45
123.45
123.45
123.45
Michael Austin.
Jul 17 '05 #2
gs
Dnia 2004-06-29 15:27, niejaki(a) Michael Austin wystukał(a) na klawiaturze:
It looks like a bug in the numer_format routine.


I suppose not in number_format. It is just where I have first seen it.
If I will do like this:

$something=191.2434;
$second=1*$something;
echo $second;

I will have 191 as output.

Byt if I will do like this:

$something=1912434/10000;
$second=$something;
echo $second;

it is 191.2434

So probably it is a bug, but I'm nearly sure that not with number_format.

Grzegorz Sowa
Jul 17 '05 #3
I'm going to vote user error here.

gs <gs@wirtual.NO.SPAM.com.pl> wrote in message news:<cb**********@korweta.task.gda.pl>...
Dnia 2004-06-29 15:27, niejaki(a) Michael Austin wystukał(a) na klawiaturze:
It looks like a bug in the numer_format routine.


I suppose not in number_format. It is just where I have first seen it.
If I will do like this:

$something=191.2434;
$second=1*$something;
echo $second;

I will have 191 as output.

Byt if I will do like this:

$something=1912434/10000;
$second=$something;
echo $second;

it is 191.2434

So probably it is a bug, but I'm nearly sure that not with number_format.

Grzegorz Sowa

Jul 17 '05 #4
(re-ordered: please don't top post)

I noticed that Message-ID:
<7a**************************@posting.google.com > from Brad Kent
contained the following:

gs <gs@wirtual.NO.SPAM.com.pl> wrote in message news:<cb**********@korweta.task.gda.pl>...
Dnia 2004-06-29 15:27, niejaki(a) Michael Austin wystukał(a) na klawiaturze:
So probably it is a bug, but I'm nearly sure that not with number_format.
I'm going to vote user error here.


Well I tried it and got error notices.
Try:

$line['myvalue']=123.45;
echo $line['myvalue']."\n";
echo number_format($line['myvalue'],2,".","")."\n";
echo "$line[myvalue]\n";
echo 1*$line['myvalue']."\n";
echo "$line[myvalue]\n";
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5

"gs" <gs@wirtual.NO.SPAM.com.pl> wrote in message
news:cb**********@korweta.task.gda.pl...
Sorry if it will be second post, but after few hours I still can't see
my previous post.

I have problem with decimal parts on Solaris (PHP+ZendOptimizer). When I
get value from MySQL (or from text file - I have had the same), it is
loosing decimal parts.

For example, let say, that from MySQL I have $line[myvalue]=123.45
Then if I will do this:

echo $line[myvalue];
echo number_format($line[myvalue],2,".","");
echo 1*$line[myvalue];

I will recive this values:

123.45
123.00 => ?????
123

Does anybody know, where is the problem?
On some other instalation (on Windows and Linux) everything is O'K.

What is more interesting, when I compute this value - let say like this:

$newvalue=1.22*$something

I will have $newvalue eqal to 150,06, which is 1.22*123
And I can do everything with it without any problems.

Hope somebody could help me solving this problem,

Grzegorz Sowa


Sounds like a locale issue to me. PHP doesn't see 123.45 as 123 + 45/100
because the Polish notation is 123,45 (comma instead of period for the
decimal point). "123.45" thus get converted to 123.
Jul 17 '05 #6
"gs" <gs@wirtual.NO.SPAM.com.pl> wrote in message
news:cb**********@korweta.task.gda.pl...
Sorry if it will be second post, but after few hours I still can't see
my previous post.

I have problem with decimal parts on Solaris (PHP+ZendOptimizer). When I
get value from MySQL (or from text file - I have had the same), it is
loosing decimal parts.

For example, let say, that from MySQL I have $line[myvalue]=123.45
Then if I will do this:

echo $line[myvalue];
echo number_format($line[myvalue],2,".","");
echo 1*$line[myvalue];

I will recive this values:

123.45
123.00 => ?????
123

Does anybody know, where is the problem?
On some other instalation (on Windows and Linux) everything is O'K.

What is more interesting, when I compute this value - let say like this:

$newvalue=1.22*$something

I will have $newvalue eqal to 150,06, which is 1.22*123
And I can do everything with it without any problems.

Hope somebody could help me solving this problem,


Run this and see what it says:

print_r(localeconv());
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ricardo | last post by:
Hi. How can I -from an ASP page- get the decimal part of a number ? Thanks in advance for all your help.
1
by: Mark | last post by:
How can I get the decimal part of a number? For example, the number is 4.25. How do I get .25? Thanks! Mark
10
by: Charles Law | last post by:
If I display a TimeSpan I get something like 00:05:17.6217891 when what I would like to see is 00:05:18 Is there an easy way to get this output? Try as I might I just can't find it.
2
by: MLH | last post by:
Say I'm walking a subset of the records in tblAddnlOwners via DAO. Suppose there are 5 records in the extract and that I MoveFirst, MoveNext and MoveNext. Then, when on the 3rd of 5 records, I...
3
by: andylole | last post by:
Hi, I've got a db table containing 5 columns(excluding id) consisting of 1.) First Half of a UK postcode 2.) Town name to which postcode belongs 3.) Latitude of Postcode 4.) Longitude of...
11
by: shiniskumar | last post by:
Ive got a double number. double n=47758.35; Inorder to get the decimal part of this number i did as follows long decPart = (long) ((n-Math.floor(n))*100); in most cases i get the correct...
4
by: demolish50 | last post by:
Please help :) If I have a number such as 25433.50 or 12.58 how can I get whats after the decimal into its own variable? Also sometimes these numbers will be 1543.3 with only one character after...
3
by: bonymuscles | last post by:
Hi ppl... Hope ur havin a good day... here''s my doubt... I need to remove the decimal part of a number declared as DOUBLE. I can NOT change the type. I need to remove jus the decimal part......
2
by: zonar00 | last post by:
int main(int argc, char* argv) { char buf = {}; _snprintf(buf, sizeof(buf) - 1, argv); return printf("%s\n", buf); } when the code is compiled under tc 3.0 the _snprintf gives an undefined...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.