473,385 Members | 2,028 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,385 software developers and data experts.

round function issue

Hi Everyone,

I am having a little problem that I am hoping someone can help me out
with. In one of my scripts, I am working with some dollar values, and
using round to change the result calculated values into a dollar value
with cents etc...so I should be getting $200.43 instead of $200.42987
etc.

The command I am using is:

$total_revenue = round(($renew+$inc_new+$national_rec+$chargeback), 2);

This had been working previously on the old server, but a few days
ago, I transferred everything to a new system, and now it is as though
the round command is ignoring the 2 for decimal places and instead
rounding up to the next dollar value.

I am not 100% sure yet if it is caused by the round command itself, or
when I perform some math on the values used in the round command yet,
the values are taken from a string, and before any calculations are
made with the values, has 0 added to the value from the string, I
think this is supposed to change it to a number instead of a
string...so I am wondering if adding the 0 is causing the problem
perhaps?

Thanks,
David

Oct 17 '07 #1
2 1703
<comp.lang.php>
<dkruger>
<Wed, 17 Oct 2007 07:33:06 -0700>
<11**********************@v29g2000prd.googlegroups .com>
I am having a little problem that I am hoping someone can help me out
with. In one of my scripts, I am working with some dollar values, and
using round to change the result calculated values into a dollar value
with cents etc...so I should be getting $200.43 instead of $200.42987
etc.

The command I am using is:

$total_revenue = round(($renew+$inc_new+$national_rec+$chargeback), 2);

This had been working previously on the old server, but a few days
ago, I transferred everything to a new system, and now it is as though
the round command is ignoring the 2 for decimal places and instead
rounding up to the next dollar value.
Never used round() but www.php.net/manual/en/function.number-format.php
might be worth a look .
--
www.vhit.co.uk
www.jpgimage.co.uk
www.phpwhois.co.uk
www.cannabiswindow.co.uk
Oct 17 '07 #2
On Oct 17, 9:54 am, Krustov <m...@privacy.netwrote:
<comp.lang.php>
<dkruger>
<Wed, 17 Oct 2007 07:33:06 -0700>
<1192631586.455946.270...@v29g2000prd.googlegroups .com>
I am having a little problem that I am hoping someone can help me out
with. In one of my scripts, I am working with some dollar values, and
using round to change the result calculated values into a dollar value
with cents etc...so I should be getting $200.43 instead of $200.42987
etc.
The command I am using is:
$total_revenue = round(($renew+$inc_new+$national_rec+$chargeback), 2);
This had been working previously on the old server, but a few days
ago, I transferred everything to a new system, and now it is as though
the round command is ignoring the 2 for decimal places and instead
rounding up to the next dollar value.

Never used round() butwww.php.net/manual/en/function.number-format.php
might be worth a look .

--www.vhit.co.ukwww.jpgimage.co.ukwww.phpwhois.co.uk www.cannabiswindow.co.uk
Thanks, I did find that it is not actually caused by the round
function, but it seems a mysql problem, so will need to check it out
over there.

Oct 17 '07 #3

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

Similar topics

9
by: joeandtel | last post by:
If I have a value that is 53.123499999, how can I round it to 53.12?
1
by: Yachi | last post by:
Hi, i need to round: 3° decimal between 1 and 5 LOW 3° decimal between 6 and 9 UP Thanks
6
by: Jef Driesen | last post by:
I need to implement a function to implement the rounding of floating point values. At the moment i have two different implementations, depending on the type of the return value (integer or double)....
3
by: shank | last post by:
I have the following equation. <% varWT = Round(CInt((rsFreePack.Fields.Item("Weight").Value)) + CInt(Session("w"))) %> Assume.... Round(CInt((rsFreePack.Fields.Item("Weight").Value)) = .12...
6
by: Penguin | last post by:
At some long ago time Steve Jorgensen answered thus: Subject: Re: How can I round a time? Newsgroups: comp.databases.ms-access Date: 1998/12/11 Access represents a date internally as a double...
17
by: nomenklatura | last post by:
Hi, System.Math.Round function is confused me. for example i want to round 3.245 in with decimal symbol Result should be = 3.25 When i try to this in vb: A = 3.245 X = Round(A, 2) then...
2
by: Radek Cerny | last post by:
Hopefully I'm just missing something obvious, but this method (or more likely the CLR/complier) has a bug where I can not use the overloaded version: Round( double value, int digits ) It always...
3
by: Altman | last post by:
OK I was having rounding problems before and I didn't realize that their was a third parameter in the round function that would tell it if it a 5 to round up. I thought adding this would fix the...
9
by: josh logan | last post by:
Hello, I need a round function that _always_ rounds to the higher integer if the argument is equidistant between two integers. In Python 3.0, this is not the advertised behavior of the built-in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.