Page 1 of 1

[SOLVED]moving the point(.) in a number

Posted: Tue Jun 08, 2004 7:25 am
by pelegk2
i want to take any number between
1.999 withought knowing in advance
its value
and to make it 0.something
(which means to move the dot to the lfet until the first time i get 0. )
for example
947->0.947
43->0.43
and so on
how can i do that>?
thnaks i nadvance
peelg

Posted: Tue Jun 08, 2004 7:32 am
by Grim...
You could use a loop:

Code: Select all

$a = 947; //or whatever
while ($a > 0.99999999)
{
    $a /= 10;
}

Posted: Tue Jun 08, 2004 9:11 am
by Grim...
Nah, don't mention it ;)

Posted: Tue Jun 08, 2004 12:03 pm
by launchcode
Or you could just do:

Code: Select all

$value = 947;
$new_value = '0.' . $value;
;) gotta love auto-type conversion!

Posted: Wed Jun 09, 2004 1:48 am
by pelegk2
thanks alot both of u:)

Posted: Wed Jun 09, 2004 3:23 am
by Grim...
:lol: LMAO at Launchcode's suggestion.

/smack head on desk

Just (bonk) add (bonk) a (bonk) zero (bonk) and (bonk) a (bonk) point (bonk) to (bonk) the (bonk) string (bonk)!

Posted: Wed Jun 09, 2004 7:04 am
by launchcode
:D