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
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)
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])
$d
0 -0500
Subject: RE: [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 kn
n php, 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 un
>> 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 unsubscrib
> -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:
>
> $elapse
> 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 f
>> 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()
> 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
__
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 wrote:
> Hi,
>
> I need to extract the first digit after the decimal point from a number
> such
> as 28.56018, which should be '5
ts.php.net
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 numb
-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
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
>
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 n
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 O
On Fri, Jan 1, 2010 at 9:20 PM, 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 d
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).
18 matches
Mail list logo