Raised This Month: $51 Target: $400
 12% 

floatpower error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
quilhos
Veteran Member
Join Date: Jun 2010
Old 10-20-2014 , 23:44   floatpower error
Reply With Quote #1

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.
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz View Post
DDDRRRRAAAAMMMMAAAAA!!!???

Put this shit on pause while i go get some popcorn!!

Last edited by quilhos; 10-20-2014 at 23:45.
quilhos is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-21-2014 , 03:31   Re: floatpower error
Reply With Quote #2

%d -> %f
__________________
Arkshine is offline
quilhos
Veteran Member
Join Date: Jun 2010
Old 10-21-2014 , 09:01   Re: floatpower error
Reply With Quote #3

What is the difference?
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz View Post
DDDRRRRAAAAMMMMAAAAA!!!???

Put this shit on pause while i go get some popcorn!!
quilhos is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-21-2014 , 09:03   Re: floatpower error
Reply With Quote #4

%d is for integers, like %i. %f is for floats.
__________________
HamletEagle is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-21-2014 , 09:04   Re: floatpower error
Reply With Quote #5

%d is for cell (integer) and %f is for float. Cells' certain integer values correspond to certain float values.
__________________
hleV is offline
quilhos
Veteran Member
Join Date: Jun 2010
Old 10-21-2014 , 09:14   Re: floatpower error
Reply With Quote #6

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
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz View Post
DDDRRRRAAAAMMMMAAAAA!!!???

Put this shit on pause while i go get some popcorn!!

Last edited by quilhos; 10-21-2014 at 09:35.
quilhos is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-21-2014 , 09:56   Re: floatpower error
Reply With Quote #7

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.
__________________
HamletEagle is offline
quilhos
Veteran Member
Join Date: Jun 2010
Old 10-21-2014 , 16:02   Re: floatpower error
Reply With Quote #8

Fixed, thx a lot mate
__________________
ELO RATING SYSTEM - SQL [COMPLETE]
Quote:
Originally Posted by Liverwiz View Post
DDDRRRRAAAAMMMMAAAAA!!!???

Put this shit on pause while i go get some popcorn!!
quilhos is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 10-22-2014 , 06:14   Re: floatpower error
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
you would do 1.%f and so on.
%.1f is the correct way
jimaway is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-22-2014 , 10:37   Re: floatpower error
Reply With Quote #10

Quote:
Originally Posted by jimaway View Post
%.1f is the correct way
Is this is possible to get it without the dot %.-1f
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:00.


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