Quote:
Originally Posted by fysiks
That will only work for values between 10,000 and 99,999,999.
What exactly are you trying to do? What situation would you only want the first 4 digits?
|
It worked for all the values I threw at it. I did have to adjust the zeros in the while check accordingly.
I needed to convert get_gametime() seconds to miliseconds and I found this post:
Quote:
Originally Posted by SchlumPF*
this might help:
PHP Code:
public fnClimbtimeToString( Float:climbtime, output[], len ) { new minutes, seconds, miliseconds; minutes = floatround( climbtime / 60.0, floatround_floor ); seconds = floatround( climbtime - minutes * 60, floatround_floor ); miliseconds = floatround( ( climbtime - ( minutes * 60 + seconds ) ) * 1000000, floatround_floor ); format( output, len, "%02i:%02i:%06i", minutes, seconds, miliseconds ); }
|
I only wanted the first few digits of the miliseconds. But then I found out that miliseconds are actually seconds * 1000.
I'm still glad I learned the method you guys posted, I'm sure it'll come in handy one day.