View Single Post
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-18-2013 , 20:39   Re: Float number calculations
Reply With Quote #5

This is how float works in pawn or in c++, so what i said that should be ok internally seems wrong.

You can read those interesting thread :
https://forums.alliedmods.net/showthread.php?t=53543
https://forums.alliedmods.net/showthread.php?t=53535
https://forums.alliedmods.net/showthread.php?t=47051

Anyway, in your case, multiply all by 10 and you can works with integers.

And if you want to print as Float, you can trick it like this :

PHP Code:
    static iNumber 800// instead of 80.0

    
new szNumber[32];
    new 
len formatex(szNumbercm(szNumber), "%d", ++iNumber); // add 1 instead of 0.1
    
szNumber[len] = szNumber[len-1];
    
szNumber[len-1] = '.';
    
client_print(idprint_chatszNumber); 
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-18-2013 at 20:49.
ConnorMcLeod is offline