Re: Need unrounded precision

From: Date: Fri, 16 Oct 2009 06:18:06 +0000
Subject: Re: Need unrounded precision
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-298903@lists.php.net to get a copy of this message
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]) $digit = $regs[1]; else print "no digit found"; -- Kind regards Kim Emax

« previous php.general (#298903) next »