AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   floatpower error (https://forums.alliedmods.net/showthread.php?t=250266)

quilhos 10-20-2014 23:44

floatpower error
 
Well I got this code and I'd like to understand why the outcome is not what is expected.
PHP Code:

    TESTE floatpower(10.0,6.0)

    
client_print(killerprint_console"TESTE: %d"TESTE

The outcome is 1232348160 instead of the correct answer(10^6).

Basicly I'm having a little of hard time working with exponent using floatpower, and I'd like some assisting fixing this, and maybe in the process I actually understand it correctly.

Arkshine 10-21-2014 03:31

Re: floatpower error
 
%d -> %f

quilhos 10-21-2014 09:01

Re: floatpower error
 
What is the difference?

HamletEagle 10-21-2014 09:03

Re: floatpower error
 
%d is for integers, like %i. %f is for floats.

hleV 10-21-2014 09:04

Re: floatpower error
 
%d is for cell (integer) and %f is for float. Cells' certain integer values correspond to certain float values.

quilhos 10-21-2014 09:14

Re: floatpower error
 
The test start to work properly but I'm sure I made some mistake on this:

PHP Code:

    div1 float(userpoints[killer]/400)
    
QA floatpower(10.0,div1)
    
    
client_print(killerprint_console"QA: %f"QA


HamletEagle 10-21-2014 09:56

Re: floatpower error
 
If div1 and QA are tagged as floats, it's fine. If you want to print just the first digit after the . you would do 1.%f and so on.

quilhos 10-21-2014 16:02

Re: floatpower error
 
Fixed, thx a lot mate :)

jimaway 10-22-2014 06:14

Re: floatpower error
 
Quote:

Originally Posted by HamletEagle (Post 2213970)
you would do 1.%f and so on.

%.1f is the correct way

Natsheh 10-22-2014 10:37

Re: floatpower error
 
Quote:

Originally Posted by jimaway (Post 2214360)
%.1f is the correct way

Is this is possible to get it without the dot %.-1f


All times are GMT -4. The time now is 05:53.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.