Re: [PHP] Need unrounded precision

2009-11-04 Thread Matthew McKay
Kim Madsen wrote: Hello Andre Dubuc wrote on 2010-01-02 02:20: Hi, I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5'. Since no one came up with the simple solution: $num = 28.56018; ereg(^[0-9]+\.([0-9]){1}, trim($num), $regs);

Re: [PHP] Need unrounded precision

2009-11-04 Thread Nathan Rixham
Matthew McKay wrote: Kim Madsen wrote: Hello Andre Dubuc wrote on 2010-01-02 02:20: Hi, I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5'. Since no one came up with the simple solution: $num = 28.56018; ereg(^[0-9]+\.([0-9]){1},

Re: [PHP] Need unrounded precision

2009-10-16 Thread Kim Madsen
Hello Andre Dubuc wrote on 2010-01-02 02:20: Hi, I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5'. Since no one came up with the simple solution: $num = 28.56018; ereg(^[0-9]+\.([0-9]){1}, trim($num), $regs); if($regs[1])

Re: [PHP] Need unrounded precision

2009-10-14 Thread Philip Thompson
: [PHP] Need unrounded precision Hmmm... Didn't think about this, but % only works with int values it was just future prof precaution since this statement is false for many other languages. In few words I am not sure PHP6 does the same ... never mind so far Good to know. In that case, I

RE: [PHP] Need unrounded precision

2009-10-12 Thread Arno Kuhl
-Original Message- From: Andre Dubuc [mailto:aajdu...@webhart.net] Sent: 02 January 2010 03:20 AM To: php-general@lists.php.net Subject: [PHP] Need unrounded precision Hi, I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5

RE: [PHP] Need unrounded precision

2009-10-12 Thread Chetan Rane
Subject: RE: [PHP] Need unrounded precision -Original Message- From: Andre Dubuc [mailto:aajdu...@webhart.net] Sent: 02 January 2010 03:20 AM To: php-general@lists.php.net Subject: [PHP] Need unrounded precision Hi, I need to extract the first digit after the decimal point from a number

Re: [PHP] Need unrounded precision

2009-10-12 Thread Diogo Neves
A simple way to do that would be: $elapsed = strval( 28.56018 ); $pos = strpos( $elapsed, '.' ); echo $elapsed[ ++$pos ]; On Sat, Jan 2, 2010 at 2:20 AM, Andre Dubuc aajdu...@webhart.net wrote: Hi, I need to extract the first digit after the decimal point from a number such as 28.56018,

RE: [PHP] Need unrounded precision

2009-10-12 Thread Andrea Giammarchi
Hmmm... Didn't think about this, but % only works with int values it was just future prof precaution since this statement is false for many other languages. In few words I am not sure PHP6 does the same ... never mind so far Regards

RE: [PHP] Need unrounded precision

2009-10-12 Thread Jaime Bozza
Hmmm... Didn't think about this, but % only works with int values it was just future prof precaution since this statement is false for many other languages. In few words I am not sure PHP6 does the same ... never mind so far Good to know. In that case, I would probably just use intval()

RE: [PHP] Need unrounded precision

2009-10-12 Thread Andrea Giammarchi
Couldn't this be done with just simple math functions? indeed: $a = 28.56018; $b = $a * 10 % 10 0; Regards _ Windows Live Hotmail: Your friends can get your Facebook updates, right

RE: [PHP] Need unrounded precision

2009-10-12 Thread Jaime Bozza
-Original Message- From: Diogo Neves [mailto:dafne...@gmail.com] Sent: Monday, October 12, 2009 9:19 AM To: Andre Dubuc Cc: php-general@lists.php.net Subject: Re: [PHP] Need unrounded precision A simple way to do that would be: $elapsed = strval( 28.56018 ); $pos = strpos

RE: [PHP] Need unrounded precision

2009-10-12 Thread Jaime Bozza
Couldn't this be done with just simple math functions? indeed: $a = 28.56018; $b = $a * 10 % 10 0; Hmmm... Didn't think about this, but % only works with int values, so $b = $a * 10 % 10; Should work as well. Jaime -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

RE: [PHP] Need unrounded precision

2009-10-12 Thread Andrea Giammarchi
, except when the integer is too big ... but this was not the case, we had to deal with 1 to 10 :-) Regards From: jbo...@mindsites.com To: an_...@hotmail.com CC: php-general@lists.php.net Date: Mon, 12 Oct 2009 11:33:10 -0500 Subject: RE: [PHP] Need unrounded precision Hmmm... Didn't think

[PHP] Need unrounded precision

2009-10-11 Thread Andre Dubuc
Hi, I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5'. I've tried a few methods to accomplish this. If I use 'ini_set' I would need to know the number of digits before the decimal (which, unfortunately, I would not have access to).

Re: [PHP] Need unrounded precision

2009-10-11 Thread Eddie Drapkin
On Fri, Jan 1, 2010 at 9:20 PM, Andre Dubuc aajdu...@webhart.net wrote: Hi, I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5'. I've tried a few methods to accomplish this. If I use 'ini_set' I would need to know the number of

Re: [PHP] Need unrounded precision [RESOLVED]

2009-10-11 Thread Andre Dubuc
Thanks Eddie, Actually while waiting for some re[lies, I resolved the problem. I realized that '$elapsed' will always have only two digits before the decimal point. Thus I was able to use 'number_format($elapsed, 2);' and to give me the desired result. Thanks for the quick reply! Andre On

Re: [PHP] Need unrounded precision

2009-10-11 Thread Jim Lucas
Andre Dubuc wrote: Hi, I need to extract the first digit after the decimal point from a number such as 28.56018, which should be '5'. I've tried a few methods to accomplish this. If I use 'ini_set' I would need to know the number of digits before the decimal (which, unfortunately, I would

Re: [PHP] Need unrounded precision

2009-10-11 Thread Andre Dubuc
Yup! I had noticed that I had forgot to reset to today's date after working on the code, just after I sent the messages. Thanks. Andre On October 11, 2009 09:14:56 pm Jim Lucas wrote: Andre Dubuc wrote: Hi, I need to extract the first digit after the decimal point from a number such