Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Stolen from bo2 I can code better than this but
- // i can not be asked to make it.
- // Thanks 3ark. I still hate you :) <3
- string_to_float( string )
- {
- floatparts = strtok( string, "." );
- if ( floatparts.size == 1 )
- {
- return int( floatparts[ 0 ] );
- }
- whole = int( floatparts[ 0 ] );
- decimal = 0;
- i = floatparts[ 1 ].size - 1;
- while ( i >= 0 )
- {
- decimal = ( decimal / 10 ) + ( int( floatparts[ 1 ][ i ] ) / 10 );
- i--;
- }
- if ( whole >= 0 )
- {
- return whole + decimal;
- }
- else
- {
- return whole - decimal;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement