Re: [PHP] Round help needed

2012-09-28 Thread Jay Blanchard
On 9/27/2012 10:05 PM, Chris Payne wrote: Hi everyone, I'm having one of those nights where nothing is working, please help What I have is this: $rounded_number = round($test, -3); Here's the problem i'm having, I need it to increment to the nearest 1000 but it seems to only work if the numbe

Re: [PHP] Round help needed

2012-09-27 Thread Daniel Brown
On Thu, Sep 27, 2012 at 11:05 PM, Chris Payne wrote: > Hi everyone, > > I'm having one of those nights where nothing is working, please help > > What I have is this: > > $rounded_number = round($test, -3); > > Here's the problem i'm having, I need it to increment to the nearest 1000 > but it seems

Re: Re: [PHP] Round with money_format

2011-09-19 Thread Cyril Lopez
2011/9/17 Bill Guion : > On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: > >> From: Cyril Lopez >> Date: September 16, 2011 10:58:28 AM EDT >> To: php-general@lists.php.net >> Subject: Round with money_format >> >> Hi, >> >> Can someone help me understand how money_format() rounds numbers ? >> >>

Re: Re: [PHP] Round with money_format

2011-09-17 Thread Richard Quadling
On 17 September 2011 15:56, Bill Guion wrote: > On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: > >> From: Cyril Lopez >> Date: September 16, 2011 10:58:28 AM EDT >> To: php-general@lists.php.net >> Subject: Round with money_format >> >> Hi, >> >> Can someone help me understand how money_format()

Re: [PHP] Round with money_format

2011-09-17 Thread Tedd Sperling
On Sep 17, 2011, at 10:56 AM, Bill Guion wrote: > On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: >> >> Can someone help me understand how money_format() rounds numbers ? >> > As someone else pointed out, rounding rules vary by locale, but I was taught > 40+ years ago in graduate school programm

Re: Re: [PHP] Round with money_format

2011-09-17 Thread Bill Guion
On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: > From: Cyril Lopez > Date: September 16, 2011 10:58:28 AM EDT > To: php-general@lists.php.net > Subject: Round with money_format > > Hi, > > Can someone help me understand how money_format() rounds numbers ? > > setlocale(LC_ALL, 'fr_FR.UTF-8')

Re: [PHP] Round with money_format

2011-09-16 Thread Stuart Dallas
Oops... On 16 Sep 2011, at 16:36, Stuart Dallas wrote: > On 16 Sep 2011, at 15:58, Cyril Lopez wrote: > >> Can someone help me understand how money_format() rounds numbers ? >> >> > setlocale(LC_ALL, 'fr_FR.UTF-8'); >> $price = 12.665; >> echo money_format('%i',$price); >> // 12.66 EUR, 12.67 E

Re: [PHP] Round with money_format

2011-09-16 Thread Stuart Dallas
On 16 Sep 2011, at 15:58, Cyril Lopez wrote: > Can someone help me understand how money_format() rounds numbers ? > > setlocale(LC_ALL, 'fr_FR.UTF-8'); > $price = 12.665; > echo money_format('%i',$price); > // 12.66 EUR, 12.67 EUR expected > > $price2 = 12.666; > echo money_format('%i',$p

Re: [PHP] Round with money_format

2011-09-16 Thread Richard Quadling
On 16 September 2011 15:58, Cyril Lopez wrote: > Hi, > > Can someone help me understand how money_format() rounds numbers ? > >  setlocale(LC_ALL, 'fr_FR.UTF-8'); >  $price = 12.665; >  echo money_format('%i',$price); >  // 12.66 EUR, 12.67 EUR expected > >  $price2 = 12.666; >  echo money_format

[PHP] Round with money_format

2011-09-16 Thread Cyril Lopez
Hi, Can someone help me understand how money_format() rounds numbers ? Misconfiguration ? Bug ? Thanks ! Cyril Config : Debian Lenny, PHP 5.3.8 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

SV: SV: [PHP] Round to a given value?

2008-12-26 Thread Anders Norrbring
> Anders Norrbring wrote: > On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote: > > Rounding an integer to the closest divisor by ten is easy with > round() and a > > negative precision, but I turn out to be lost if I want to round > >> to > >>> a > given > > numbe

Re: SV: [PHP] Round to a given value?

2008-12-25 Thread Jim Lucas
Anders Norrbring wrote: On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote: Rounding an integer to the closest divisor by ten is easy with round() and a negative precision, but I turn out to be lost if I want to round to a given number.. Example, round to the closest 5000, or close

SV: [PHP] Round to a given value?

2008-12-25 Thread Anders Norrbring
> > > On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote: > > > > Rounding an integer to the closest divisor by ten is easy with > > > round() and a > > > > negative precision, but I turn out to be lost if I want to round > to > > a > > > given > > > > number.. > > > > > > > > Example, round

SV: [PHP] Round to a given value?

2008-12-25 Thread Anders Norrbring
> > On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote: > > > Rounding an integer to the closest divisor by ten is easy with > > round() and a > > > negative precision, but I turn out to be lost if I want to round to > a > > given > > > number.. > > > > > > Example, round to the closest 5000

SV: [PHP] Round to a given value?

2008-12-24 Thread Anders Norrbring
> On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote: > > Rounding an integer to the closest divisor by ten is easy with > round() and a > > negative precision, but I turn out to be lost if I want to round to a > given > > number.. > > > > Example, round to the closest 5000, or closest 400?

Re: [PHP] Round to a given value?

2008-12-24 Thread Ashley Sheridan
On Wed, 2008-12-24 at 20:38 +0100, Anders Norrbring wrote: > Rounding an integer to the closest divisor by ten is easy with round() and a > negative precision, but I turn out to be lost if I want to round to a given > number.. > > Example, round to the closest 5000, or closest 400? Any great ideas

[PHP] Round to a given value?

2008-12-24 Thread Anders Norrbring
Rounding an integer to the closest divisor by ten is easy with round() and a negative precision, but I turn out to be lost if I want to round to a given number.. Example, round to the closest 5000, or closest 400? Any great ideas? Thanks, and merry x-mas! Anders. -- PHP General Mailing List (

RE: [PHP] round()

2007-10-12 Thread tedd
At 12:55 PM -0700 10/12/07, Instruct ICC wrote: > > > Yes, but precision is not the issue. > > php -r '$t=123.45; echo $t . "\n"; $t+=0.001; echo $t . "\n";' 123.45 123.451 php -r '$t=123.45; echo $t . "\n"; $t+=0.0001; echo $t . "\n";' 123.45 123.45 php -r '$t=123.45

RE: RE: [PHP] round()

2007-10-12 Thread tedd
At 11:08 AM -0700 10/12/07, =?UTF-8?Q?J=C3=BCrgen_Wind?= wrote: It's a question of what you expect from a rounding function. If you work with reals on a computer you always have a bit of "fuzzynes" due to the internal conversions from float to binary and resulting truncations. It is only "reals

RE: [PHP] round()

2007-10-12 Thread Instruct ICC
> > > Yes, but precision is not the issue. > > > php -r '$t=123.45; echo $t . "\n"; $t+=0.001; echo $t . "\n";' 123.45 123.451 php -r '$t=123.45; echo $t . "\n"; $t+=0.0001; echo $t . "\n";' 123.45 123.45 php -r '$t=123.45678901234567; echo $t . "\n";' 123.45678901235 Ge

RE: [PHP] round()

2007-10-12 Thread Instruct ICC
> > Yes, but precision is not the issue. > > > > It doesn't make any difference if you are rounding. > > You still have to make a decision Uuhm, what was $t on the platform before the round please (the += .000..1 post)? Then that will confirm that precision is not the problem. Als

RE: RE: [PHP] round()

2007-10-12 Thread Jürgen Wind
tedd wrote: > > At 7:30 PM -0700 10/11/07, Instruct ICC wrote: >> >> >>Now I see why BCMath was mentioned. > > Yes, but precision is not the issue. > > It doesn't make any difference if you are rounding. > > (a) 1.489123451985765 > > or > > (b) 148912345198576.5 > > You still have to make

Re: [PHP] round()

2007-10-12 Thread tedd
At 10:22 AM -0400 10/11/07, Nathan Nobbe wrote: On 10/11/07, tedd <[EMAIL PROTECTED]> wrote: At 4:18 PM -0600 10/10/07, <[EMAIL PROTECTED]> wrote: I disagree. I will need to see an example where the round() is inaccurate. You may disagree

Re: [PHP] round()

2007-10-11 Thread Nathan Nobbe
On 10/11/07, tedd <[EMAIL PROTECTED]> wrote: > > At 4:18 PM -0600 10/10/07, <[EMAIL PROTECTED]> wrote: > >I disagree. I will need to see an example where the round() is > inaccurate. > > > You may disagree if you wish, but the php function round() is > inaccurate by definition -- all *rounding* alg

RE: [PHP] round()

2007-10-11 Thread tedd
At 4:18 PM -0600 10/10/07, <[EMAIL PROTECTED]> wrote: I disagree. I will need to see an example where the round() is inaccurate. You may disagree if you wish, but the php function round() is inaccurate by definition -- all *rounding* algorithms are inaccurate. My claim is the there are more

Re: [PHP] round()

2007-10-10 Thread Bob Chatman
Why arent you just using sprintf? $var = 5.555; printf("%.2f", $var); # output : 5.56 printf("%.1f", $var); # output : 5.6 printf("%.0f", $var); # output : 6 On 10/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > While we're entertaining algorithms, has anyone else noticed that > > > ph

RE: [PHP] round()

2007-10-10 Thread admin
> While we're entertaining algorithms, has anyone else noticed that > php's round() isn't the most accurate algorithm to round? If you will refer to chafy's reply on 28-Feb-2007 06:13 The function round numbers to a given precision.

RE: [PHP] round()

2007-10-10 Thread Instruct ICC
> While we're entertaining algorithms, has anyone else noticed that > php's round() isn't the most accurate algorithm to round? For those that replied that there is a problem, can you provide examples? precision The optional number of decimal digits to round to, defaults to 0

Re: [PHP] round()

2007-10-10 Thread Nathan Nobbe
On 10/10/07, tedd <[EMAIL PROTECTED]> wrote: > > Hi gang: > > While we're entertaining algorithms, has anyone else noticed that > php's round() isn't the most accurate algorithm to round? > > there is a function that uses the bc math library on the bc math page

Re: [PHP] round()

2007-10-10 Thread David Giragosian
On 10/10/07, tedd <[EMAIL PROTECTED]> wrote: > > Hi gang: > > While we're entertaining algorithms, has anyone else noticed that > php's round() isn't the most accurate algorithm to round? > > Cheers, > > tedd > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com

[PHP] round()

2007-10-10 Thread tedd
Hi gang: While we're entertaining algorithms, has anyone else noticed that php's round() isn't the most accurate algorithm to round? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe

Re: [PHP] Round

2007-08-29 Thread Koen van den Boogaart
Some information from Wikipedia: http://en.wikipedia.org/wiki/Negative_zero. Says in math a negative zero doesn't exist, in computing it does. Strange thing is that PHP4 and 5 until at least 5.1.6 (see Jim Lucas) round() gives a float(0) and then 5.2.3 gives float(-0). I'll report a bug. ""Rich

Re: [PHP] Round

2007-08-29 Thread Richard Lynch
On Wed, August 29, 2007 11:38 am, Zoltán Németh wrote: > 2007. 08. 29, szerda keltezéssel 09.29-kor Jim Lucas ezt írta: >> Daniel Brown wrote: >> > On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote: >> >> Koen van den Boogaart wrote: >> >>> No, I want it to go to float(0), so minus the minus. "

Re: [PHP] Round

2007-08-29 Thread Jim Lucas
PHP-Gen wrote: I believe there is some confusion on what ABS actually does. Ignoring all the rounding that you are trying to do ABS is a very simple function. ABS definition: Returns the absolute value of number. What that means is. Abs(1) = 1 Abs(2) = 2 Abs(3) = 3 Abs(0) = 0 Abs(-1) = 1 Abs(

RE: [PHP] Round

2007-08-29 Thread PHP-Gen
ction. Unless someone has some trick that I don't know about, ABS will NEVER return a negative number. -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 29, 2007 1:43 PM To: Daniel Brown Cc: Zoltán Németh; php-general@lists.php.net Subject: Re: [PHP] Rou

Re: [PHP] Round

2007-08-29 Thread Koen van den Boogaart
I'm running 5.2.3. Reaction on above discussion: of course this problem can be solved with all sorts of solutions, but my question is: is it good that a function returns a number that doesn't exist? I once posted a bug report about a wrong round()-result, though it wasn't a bug, but a consequenc

Re: [PHP] Round

2007-08-29 Thread Jim Lucas
Daniel Brown wrote: On 8/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote: Think this through before you respond... Try this does this give you the desired results? What if I expected -1 for the last answer? It didn't take much thinking this time if you were expecting -1 for the las

Re: [PHP] Round

2007-08-29 Thread Daniel Brown
On 8/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote: > > Think this through before you respond... > > > > Try this > > > > > var_dump( round(-0.26) ); > > var_dump( abs( round(-0.26) ) ); > > var_dump( round(-1.26) ); > > var_dump( abs( round(-1.26) ) ); > > ?> > > > > does this give you the desir

Re: [PHP] Round

2007-08-29 Thread Zoltán Németh
2007. 08. 29, szerda keltezéssel 09.29-kor Jim Lucas ezt írta: > Daniel Brown wrote: > > On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote: > >> Koen van den Boogaart wrote: > >>> No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in > >>> math, as far as I know. Probably a p

Re: [PHP] Round

2007-08-29 Thread Richard Heyes
What if I expected -1 for the last answer? Then only use abs() if the result from round() is zero; -- Richard Heyes +44 (0)844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php

Re: [PHP] Round

2007-08-29 Thread Jim Lucas
Daniel Brown wrote: On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote: Koen van den Boogaart wrote: No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in math, as far as I know. Probably a precision thing. Ok, then try abs() first then. -- Richard Heyes +44 (0)844 801 1

Re: [PHP] Round

2007-08-29 Thread Daniel Brown
On 8/29/07, Richard Heyes <[EMAIL PROTECTED]> wrote: > Koen van den Boogaart wrote: > > No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in > > math, as far as I know. Probably a precision thing. > > Ok, then try abs() first then. > > -- > Richard Heyes > +44 (0)844 801 1072

Re: [PHP] Round

2007-08-29 Thread Richard Heyes
Koen van den Boogaart wrote: No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in math, as far as I know. Probably a precision thing. Ok, then try abs() first then. -- Richard Heyes +44 (0)844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk soft

Re: [PHP] Round

2007-08-29 Thread Jim Lucas
Koen van den Boogaart wrote: Is it expected behaviour that outputs float(-0) What version of PHP are you running. I'm running 5.1.6 and I get float(0) -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Nigh

Re: [PHP] Round

2007-08-29 Thread Koen van den Boogaart
No, I want it to go to float(0), so minus the minus. "-0" doesn't exist in math, as far as I know. Probably a precision thing. "Richard Heyes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Koen van den Boogaart wrote: >> Is it expected behaviour that >> >> >> >> outputs >> >> fl

Re: [PHP] Round

2007-08-29 Thread Richard Heyes
Koen van den Boogaart wrote: Is it expected behaviour that outputs float(-0) Yes. You (probably) want: http://uk.php.net/manual/en/function.round.php -- Richard Heyes +44 (0)844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost o

[PHP] Round

2007-08-29 Thread Koen van den Boogaart
Is it expected behaviour that outputs float(-0) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Rounding -- was [PHP] round to nearest 500?

2007-02-14 Thread tedd
At 8:40 PM +0100 2/13/07, Satyam wrote: - Original Message - From: "Jon Anderson" <[EMAIL PROTECTED]> The reason is simple: 0: No rounding. It's already there. (8.0 doesn't need to be rounded to 8 - it already *is* 8.) 1-4: You round down -> 4 of 9 times you round down. 5-9: You round

Re: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
I don't buy "zero doesn't count". But again, this is getting into serious math. It should be good enough to say 0-4 = 0, 5-9 = 10, but if you don't keep strict high precision throughout the whole process and round at every step, things are going to be off no matter what. It's just a matter of

Re: [PHP] round to nearest 500?

2007-02-13 Thread Satyam
- Original Message - From: "Jon Anderson" <[EMAIL PROTECTED]> [EMAIL PROTECTED] wrote: hah yeah, always worth a little skepticism, but it seemed to make some kind of sense. If you always round up or always round down, that's obviously not right and you end up losing potentially a l

Re: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
Ahh.. good call. http://en.wikipedia.org/wiki/Rounding Apprently it's called "banker's rounding" or "statistician's rounding" and is a little more complicated than just looking at the odd/even of the digit being arounded. This is starting to get into some heavy math theory and scary stuff tha

RE: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
Ok, screw work.. it's snowing out anyway (not that that makes a real difference to doing PHP work inside), curiosity got the better of me. btw.. the "banker" rounding code here was pulled from the round() manual page. It's not what I read before, but it's the same concept: function bankers_rou

Re: [PHP] round to nearest 500?

2007-02-13 Thread Jon Anderson
[EMAIL PROTECTED] wrote: hah yeah, always worth a little skepticism, but it seemed to make some kind of sense. If you always round up or always round down, that's obviously not right and you end up losing potentially a lot of money or over-estimating the money involved. Founding up for 5 th

RE: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
hah yeah, always worth a little skepticism, but it seemed to make some kind of sense. If you always round up or always round down, that's obviously not right and you end up losing potentially a lot of money or over-estimating the money involved. Founding up for 5 through 9 and down for 0 thro

RE: [PHP] round to nearest 500?

2007-02-13 Thread Tim
> Supposedly this is an accounting trick that > ultimatley works out in the end for proper rounding of money > values. Yeah works out for who? Bet it doesn't for the guy paying :P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] round to nearest 500?

2007-02-13 Thread tg-php
For downward rounding, you'd always want to use floor() and use ceil() for rounding up. round() rounds up on a 5, down on a 4 and below. Example: echo round(141.074, 2); // 141.07 echo round(141.065, 2); // 141.07 I thought round() (or maybe it was a rounding function in another language or

Re: [PHP] round to nearest 500?

2007-02-13 Thread tedd
At 7:57 PM +0100 2/12/07, Marc Weber wrote: On Mon, 12 Feb 2007 18:02:41 +0100, <[EMAIL PROTECTED]> wrote: Is there an easy way in php to round to the nearest 500? Yeah $rouned = round($val/500) * 500; I've always questioned the round() function. I believe it has a downward bias, am I wrong

Re: [PHP] round to nearest 500?

2007-02-12 Thread Marc Weber
On Mon, 12 Feb 2007 18:02:41 +0100, <[EMAIL PROTECTED]> wrote: Is there an easy way in php to round to the nearest 500? Yeah $rouned = round($val/500) * 500; Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] round to nearest 500?

2007-02-12 Thread Tim
> -Message d'origine- > De : Robert Cummings [mailto:[EMAIL PROTECTED] > Envoyé : lundi 12 février 2007 18:00 > À : blackwater dev > Cc : php-general@lists.php.net > Objet : Re: [PHP] round to nearest 500? > > On Mon, 2007-02-12 at 11:52 -0500, blackwat

Re: [PHP] round to nearest 500?

2007-02-12 Thread Robert Cummings
On Mon, 2007-02-12 at 11:59 -0500, Jon Anderson wrote: > blackwater dev wrote: > > Is there an easy way in php to round to the nearest 500? > > > > So if I have 600, I 500 and if I have 800 I want 1000? > Multiply by 2, round to 1000, divide by 2. Maybe there's an easier way, > but that's what I

Re: [PHP] round to nearest 500?

2007-02-12 Thread tg-php
$num = "749"; $rounded = round($num * 2, -3) / 2; echo $rounded; -TG = = = Original message = = = Is there an easy way in php to round to the nearest 500? So if I have 600, I 500 and if I have 800 I want 1000? Thanks! ___ Sent by eProm

Re: [PHP] round to nearest 500?

2007-02-12 Thread Robert Cummings
On Mon, 2007-02-12 at 11:52 -0500, blackwater dev wrote: > Is there an easy way in php to round to the nearest 500? > > So if I have 600, I 500 and if I have 800 I want 1000? This should work: Cheers, Rob. -- .. | InterJinn Applicati

Re: [PHP] round to nearest 500?

2007-02-12 Thread Jon Anderson
blackwater dev wrote: Is there an easy way in php to round to the nearest 500? So if I have 600, I 500 and if I have 800 I want 1000? Multiply by 2, round to 1000, divide by 2. Maybe there's an easier way, but that's what I use. 600*2 = 1200, round(1200,-3) = 1000, 1000/2 = 500 800*2 = 1600,

[PHP] round to nearest 500?

2007-02-12 Thread blackwater dev
Is there an easy way in php to round to the nearest 500? So if I have 600, I 500 and if I have 800 I want 1000? Thanks!

Re: [PHP] round behavior changed

2006-05-20 Thread tedd
At 3:17 PM -0500 5/19/06, Richard Lynch wrote: On Fri, May 19, 2006 1:27 pm, Sébastien Guay wrote: I searched the archives but did not found anything. It seem that the round function behavior has changed in php 4.4.x (I don't have 4.4.1 handy for testing). In 4.3.11, the output of round("

Re: [PHP] round behavior changed

2006-05-19 Thread Richard Lynch
On Fri, May 19, 2006 1:27 pm, Sébastien Guay wrote: > I searched the archives but did not found anything. > > It seem that the round function behavior has changed in php 4.4.x (I > don't > have 4.4.1 handy for testing). > > In 4.3.11, the output of round("23.005",2) is 23.01 which is > mathematical

Re: [PHP] round behavior changed

2006-05-19 Thread tg-php
I seem to remember something about rounding functions and accounting.. that there's a rule in accounting that says if the trailing number is even you round down, odd you round up.. or something like that. I know that's different than standard 'math' but in accounting it apparently helps deal wi

[PHP] round behavior changed

2006-05-19 Thread Sébastien Guay
Hi, I searched the archives but did not found anything. It seem that the round function behavior has changed in php 4.4.x (I don't have 4.4.1 handy for testing). In 4.3.11, the output of round("23.005",2) is 23.01 which is mathematically correct. In 4.4.2, the output is 23 which is not correct.

Re: [PHP] Round with ONE-decimal... always...

2005-09-12 Thread Jordan Miller
besides sprintf, number_format will also do it: number_format(6, 1, ',', '');// Outputs '6,0' Jordan On Sep 12, 2005, at 3:52 AM, Gustav Wiberg wrote: Hi there! I want to adjust the round() -function a little... If I put round(6,0) there will be an output of 6 If I put round(6,32) th

Re: [PHP] Round with ONE-decimal... always...

2005-09-12 Thread Gustav Wiberg
Thanx! /G - Original Message - From: "George Pitcher" <[EMAIL PROTECTED]> To: "Gustav Wiberg" <[EMAIL PROTECTED]> Sent: Monday, September 12, 2005 10:55 AM Subject: RE: [PHP] Round with ONE-decimal... always... Look at sprint_f() in the manual.

[PHP] Round with ONE-decimal... always...

2005-09-12 Thread Gustav Wiberg
Hi there! I want to adjust the round() -function a little... If I put round(6,0) there will be an output of 6 If I put round(6,32) there will be an output of 6,3 I want it to have 6,0 instead of just 6... I guess there is an easy solution to this? Suggestions? /G http://www.varupiraten.se/

Re: [PHP] Round to the nearest X - SOLVED

2005-04-29 Thread Chris Boget
Thank you for everyone's suggestions. Using them (and a few other things I've found elsewhere), I've come up with the following function: function roundToNearest( $number, $toNearest = 5 ) { $retval = 0; $mod = $number % $toNearest; if( $mod >= 0 ) { $retval = ( $mod > ( $toNearest /

RE: [PHP] Round to the nearest X

2005-04-28 Thread Jared Williams
> I realize this is a dumb question but I just can't come up > with an equation that will do this and I don't see an > internal PHP function (for version 4.3) that will do this... > Basically I need to come up with an equation/algorithm that > will round any number up/down to the nearest X. >

Re: [PHP] Round to the nearest X

2005-04-28 Thread Greg Donald
On 4/28/05, Greg Donald <[EMAIL PROTECTED]> wrote: > do { > $num++; > } while( $num % 500 ); Actually that fails for the base number 500. This works for everything: #!/usr/bin/php > ./round.php 0 > ./round.php 499 500 > ./round.php 500 500 > ./round.php 501 1000 -- Greg Donald Zend C

Re: [PHP] Round to the nearest X

2005-04-28 Thread Brent Baisley
I think the formula you are looking for is something like this: round( y/x, 0) * x With y being your number and x being the nearest increment number to round to. On Apr 28, 2005, at 4:10 PM, Chris Boget wrote: I realize this is a dumb question but I just can't come up with an equation that will d

Re: [PHP] Round to the nearest X

2005-04-28 Thread Greg Donald
On 4/28/05, Chris Boget <[EMAIL PROTECTED]> wrote: > I realize this is a dumb question but I just can't come > up with an equation that will do this and I don't see an > internal PHP function (for version 4.3) that will do this... > Basically I need to come up with an equation/algorithm > that will

[PHP] Round to the nearest X

2005-04-28 Thread Chris Boget
I realize this is a dumb question but I just can't come up with an equation that will do this and I don't see an internal PHP function (for version 4.3) that will do this... Basically I need to come up with an equation/algorithm that will round any number up/down to the nearest X. I tried using y

Re: [PHP] round?

2005-04-16 Thread trlists
On 16 Apr 2005 Chris Knipe wrote: > I'm not sure if round() is what I am after. I want to round whole numbers > to the closest 10 - thus, not decimals, etc. Just use a precision of -1. For example round(125, -1) will return 130. -- Tom -- PHP General Mailing List (http://www.php.net/) To u

[PHP] round?

2005-04-16 Thread Chris Knipe
Hi, I'm not sure if round() is what I am after. I want to round whole numbers to the closest 10 - thus, not decimals, etc. For example. 11.23 = 10 14.76 = 10 15.23 = 20 18.53 = 20 Thanks, -- Chris. I love deadlines. I especially love the whooshing sound they make as they fly by..." - Douglas Ad

Re: [PHP] round

2005-01-26 Thread Sergio Gorelyshev
On Wed, 26 Jan 2005 06:32:32 -0500 blackwater dev <[EMAIL PROTECTED]> wrote: > Hello, > > I have these values: > > 8.26456 > 9.7654 > 3. > 5.2689 > > and I want them rounded to two decimal places so I use the round : > round($value,2) which gives me, for example: > 8.26 You can try the spr

RE: [PHP] round

2005-01-26 Thread Gerard Petersen
You can use the number_format($number, decimal_places) function. -Original Message- From: blackwater dev [mailto:[EMAIL PROTECTED] Sent: 26 January 2005 01:33 PM To: php-general@lists.php.net Subject: [PHP] round Hello, I have these values: 8.26456 9.7654 3. 5.2689 and I want

[PHP] round

2005-01-26 Thread blackwater dev
Hello, I have these values: 8.26456 9.7654 3. 5.2689 and I want them rounded to two decimal places so I use the round : round($value,2) which gives me, for example: 8.26 But, it also gives me 3 instead of 3.00. How can I round but retain the 0's? Thanks! -- PHP General Mailing List (htt

RE: [PHP] Round() behaviour issue

2003-12-16 Thread Ford, Mike [LSS]
On 16 December 2003 11:13, Scott McDaid wrote: > Hi there. I've been looking at the behaviour of the round > functionality in PHP. We're currently still using v4.2.3, (but the > documentation seems to > suggest it's the same for versions after this). > > Doing the following rounds always rounds *

Re: [PHP] Round() behaviour issue

2003-12-16 Thread Eugene Lee
On Tue, Dec 16, 2003 at 11:13:25AM +, Scott McDaid wrote: : : Hi there. I've been looking at the behaviour of the round functionality in : PHP. We're currently still using v4.2.3, (but the documentation seems to : suggest it's the same for versions after this). : : Doing the following round

[PHP] Round() behaviour issue

2003-12-16 Thread Scott McDaid
Hi there. I've been looking at the behaviour of the round functionality in PHP. We're currently still using v4.2.3, (but the documentation seems to suggest it's the same for versions after this). Doing the following rounds always rounds *up* to the nearest whole number. i.e. 0.5 => 1 1.5 => 2

Re: [PHP] Round a number

2003-10-03 Thread Marek Kilimajer
echo (iny)$number; Shaun wrote: Hi, I have a query that returns a number from culculation in my table. It returns say 4.00, 8.75, 0.00, 12.50 etc. How format the number so that the trailing zeros aer removed i.e. 4, 8.75, 0, 12.5 etc? Thanks for your help -- PHP General Mailing List (http://ww

[PHP] Round a number

2003-10-03 Thread Shaun
Hi, I have a query that returns a number from culculation in my table. It returns say 4.00, 8.75, 0.00, 12.50 etc. How format the number so that the trailing zeros aer removed i.e. 4, 8.75, 0, 12.5 etc? Thanks for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visi

Re: [PHP] Round Off $ prices

2003-06-04 Thread Joci
Hi! ceil -- Round fractions up round -- Rounds a float floor -- Round fractions down Joe - Original Message - From: "Ralph" <[EMAIL PROTECTED]> To: "PHP General Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, June 04, 2003 2:51 PM Subject: [PHP] Round

[PHP] Round Off $ prices

2003-06-04 Thread Ralph
How do I round off prices to the like rounding off $24.80 to $25? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Round robin script revisited..

2002-12-30 Thread Chad Day
, $last_team); if ($even) { array_push($teamarray, $last_team_save); } Hope this helps anyone else who needs it. Chad -Original Message- From: Chad Day [mailto:[EMAIL PROTECTED]] Sent: Monday, December 30, 2002 2:03 PM To: php general Subject: RE: [PHP] Round robin

RE: [PHP] Round robin script revisited..

2002-12-30 Thread Chad Day
array_push($teamarray, $last_team); } */ } // echo ''; print_r($games); ?> -Original Message- From: Chad Day [mailto:[EMAIL PROTECTED]] Sent: Monday, December 30, 2002 10:57 AM To: php general Subject: [PHP] Round robin script revisited.. I was trying to find a scri

[PHP] Round robin script revisited..

2002-12-30 Thread Chad Day
I was trying to find a script to do round robin pairings for a sports schedule generator.. I was able to come across one in Perl, and am in the process of trying to convert it to PHP, but since my perl knowledge is a bit (well, a lot) lacking, I was hoping someone could help.. Perl script: http:

Re: [PHP] ROUND inconsistency

2001-04-13 Thread Philip Hallstrom
In article <9b6c4v$m41$[EMAIL PROTECTED]> you write: >Correction, MySQL is not returning floor, since it returns 2 for round(1.5). - I >didn't see it. >MySQL should not return 2 for round(2.5), but it should return 3. I think it's >MySQL bug. > >How about ask in MySQL mailing list? I don't think

Re: [PHP] ROUND inconsistency

2001-04-13 Thread Yasuo Ohgaki
> 2 > > 3 > > > > This discrepancy causes a difficulty in programming PHP and MySQL together, > > for example, because all of the rounding must be done in either PHP or > > MySQL but not both partially unless you want conflicting data. > > > > I would li

Re: [PHP] ROUND inconsistency

2001-04-12 Thread Yasuo Ohgaki
This discrepancy causes a difficulty in programming PHP and MySQL together, > for example, because all of the rounding must be done in either PHP or > MySQL but not both partially unless you want conflicting data. > > I would like to see MySQL ROUND() syntax expand to be ROUND(X,D,

[PHP] ROUND inconsistency

2001-04-12 Thread Lee Howard
partially unless you want conflicting data. I would like to see MySQL ROUND() syntax expand to be ROUND(X,D,M) where optional M value indicates the method of rounding, the default being the current method. I would also like to see PHP round() syntax expand to be double round (double val [, int

SV: [PHP] round up number

2001-03-14 Thread Johan Holst Nielsen
>How do I round up a lot of decimal number like 10.232656898 to be 10.23 ? Should I use this? >$num = 10.26564787; >$Rnum = round($num); >What would be the function I am looking for and how? Try: $num = 10.26564787; $Rnum = round($num, 2); /Johan -- PHP General Mailing List (http://www.php.n

[PHP] round up number

2001-03-14 Thread Jacky
How do I round up a lot of decimal number like 10.232656898 to be 10.23 ? Should I use this? $num = 10.26564787; $Rnum = round($num); What would be the function I am looking for and how? Jack [EMAIL PROTECTED] "There is nothing more rewarding than reaching the goal you set for yourself"

Re: [PHP] round

2001-01-31 Thread AJDIN BRANDIC
Oh, number_format (float number, int decimals, string dec_point, string thousands_sep) Sorry Ajdin On Wed, 31 Jan 2001, AJDIN BRANDIC wrote: > Hi > > Lets say $foo=20.12345 > > In php4 you can use : $foo=$round($foo,2); to get $foo=20.12 > > What can I use in php3 to get the same result

[PHP] round

2001-01-31 Thread AJDIN BRANDIC
Hi Lets say $foo=20.12345 In php4 you can use : $foo=$round($foo,2); to get $foo=20.12 What can I use in php3 to get the same result. $foo=$round($foo); gives me $foo=20 Not what I realy want??? Thanks Ajdin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMA

  1   2   >