Re: PHP and Double?

From: Date: Wed, 18 Apr 2001 20:51:56 +0000
Subject: Re: PHP and Double?
Groups: php.general 
Request: Send a blank email to php-general+get-49265@lists.php.net to get a copy of this message
"Jason Caldwell" <jason@thinkingman.org> wrote: > how can i separate the digits in a Double number? > > for example: > > if i have 3.2 i would like to separate the digits into 3 and 2 and assign > each to its own variable, like so > > numb1 = 3 > numb2 = 2 Use explode() to explode on the "." and save into an array. Key 0 will be the integer and key 1 will be the decimal component (without the "."). Or if you don't like that use floor() to round it down to next lowest integer and save that as $integer and then subtract it from the original value to get the decimal component and use substr() to return everything, but the first character. Clearly, the first method is cleaner, but I posed the second option (which I'd never use) just to demonstrate there are plenty of solutions for most situations. -- Steve Werby President, Befriend Internet Services LLC http://www.befriend.com/

« previous php.general (#49265) next »