Raised This Month: $ Target: $400
 0% 

[Pawn] Negative Exponents.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SkydiveX
Member
Join Date: Jul 2012
Location: England
Old 10-19-2012 , 15:08   [Pawn] Negative Exponents.
Reply With Quote #1

Its all in the question.

Attempting to do
Code:
SetEntityGravity(Client, fSize^-1);
in this case if fSize would equal 2
Code:
 2^-1 = 0.5
Is there some way I could go about doing this
__________________

_____________________________________________ _______________
Pastafarian and proud!
SkydiveX is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-19-2012 , 15:53   Re: [Pawn] Negative Exponents.
Reply With Quote #2

I don't see anything in the SoucePawn getting started guide that talks about exponents, so I have to assume it doesn't support them as an operator.

However, the Pow function exists. Just be aware that all 3 arguments have to be floats. So, with the values you gave:

PHP Code:
new Float:result Pow(float(2), float(-1)); 
Note that you can also write 2.0 and -1.0 to get floats; I just wrote it this way in case you were using variables.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 10-19-2012 , 16:15   Re: [Pawn] Negative Exponents.
Reply With Quote #3

If you're just going to raise fSize to power of -1, you may as well just use:

Code:
SetEntityGravity(Client, 1/fSize);
__________________
11530 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-19-2012 , 21:32   Re: [Pawn] Negative Exponents.
Reply With Quote #4

Symbol ^ is bitwise XOR.
__________________
FaTony is offline
SkydiveX
Member
Join Date: Jul 2012
Location: England
Old 10-20-2012 , 10:00   Re: [Pawn] Negative Exponents.
Reply With Quote #5

Thanks! Love You Guys <3. NO HOMO
__________________

_____________________________________________ _______________
Pastafarian and proud!
SkydiveX is offline
SkydiveX
Member
Join Date: Jul 2012
Location: England
Old 10-20-2012 , 10:03   Re: [Pawn] Negative Exponents.
Reply With Quote #6

Quote:
Originally Posted by 11530 View Post
If you're just going to raise fSize to power of -1, you may as well just use:

Code:
SetEntityGravity(Client, 1/fSize);
Crap.... I feel like an idiot now.
__________________

_____________________________________________ _______________
Pastafarian and proud!
SkydiveX is offline
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 14:34.


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