manipulating decimals

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ianmullineaux
Forum Newbie
Posts: 4
Joined: Thu Oct 23, 2008 7:28 am

manipulating decimals

Post by ianmullineaux »

Hi
I need to be able to seperate a decimal into two parts - the numbers before the decimal and those after and store them in 2 variables with no rounding taking place...

for example:

for the number 45.25

$a = 45
$b = 25

Can someone point me in the right direction please
Thanks

Ian
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: manipulating decimals

Post by onion2k »

Code: Select all

$number = 46.25;
$a = floor($number);
$b = $number - $a;
Post Reply