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
[SOLVED]moving the point(.) in a number
Moderator: General Moderators
You could use a loop:
Code: Select all
$a = 947; //or whatever
while ($a > 0.99999999)
{
$a /= 10;
}- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
Or you could just do:
gotta love auto-type conversion!
Code: Select all
$value = 947;
$new_value = '0.' . $value;- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact: