> -----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( $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, which should be '5'.


Couldn't this be done with just simple math functions?


$a = 28.56018;
$b = intval(($a*10)-(intval($a)*10));

or:

$a = 28.56018;
$b = intval(($a-intval($a))*10);


Jaime


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to