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

Solved Exponential function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-24-2017 , 13:09   Exponential function
Reply With Quote #1

Is there an equivalent of http://www.cplusplus.com/reference/cmath/exp/ in pawn?!?! I have searched, but didn't found anything...

EDIT: Also I need equivalent of http://www.cplusplus.com/reference/cmath/log/ in pawn. I found floatlog, but I guess is not the same, because it returns log(value) / log(base)
https://github.com/alliedmodders/amx...float.cpp#L292

Last edited by KiLLeR.; 09-24-2017 at 20:08.
KiLLeR. is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-24-2017 , 14:01   Re: Exponential function
Reply With Quote #3

power requires 2nd parameter, while exp doesn't...

floatlog is not the same:

PAWN:
Code:
server_print("Log: %f", floatlog(5.0));
Code:
Log: 0.698970
C++:
Code:
std::cout << "Log: " << log(5.0) << std::endl;
Code:
Log: 1.60944

Last edited by KiLLeR.; 09-24-2017 at 14:12.
KiLLeR. is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 09-24-2017 , 14:12   Re: Exponential function
Reply With Quote #4

Quote:
Originally Posted by KiLLeR. View Post
power requires 2nd parameter, while exp doesn't...
Code:
#define floatexp(%0) floatpower(2.7182818, %0)
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-24-2017 , 14:13   Re: Exponential function
Reply With Quote #5

Quote:
Originally Posted by PRoSToTeM@ View Post
Code:
#define floatexp(%0) floatpower(2.7182818, %0)
Okay, thanks you, look at my post above because I updated it.
KiLLeR. is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 09-24-2017 , 14:16   Re: Exponential function
Reply With Quote #6

Quote:
Originally Posted by KiLLeR. View Post
floatlog is not the same:
Because floatlog default base is 10, while stdc++ log base is e.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-24-2017 , 14:17   Re: Exponential function
Reply With Quote #7

Quote:
Originally Posted by KiLLeR. View Post
EDIT: Also I need equivalent of http://www.cplusplus.com/reference/cmath/log/ in pawn. I found floatlog, but I guess is not the same, because it returns log(value) / log(base)
https://github.com/alliedmodders/amx...float.cpp#L292
log() in C++ is log base e. So, the log function in AMX Mod X simply requires you to specify the base as the second parameter. So, if you want log base e, you would provide the numeric value of e as the second parameter.

If you want an explanation as to why log(value)/log(base) is the same thing, see here.
__________________
fysiks is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-24-2017 , 14:33   Re: Exponential function
Reply With Quote #8

Thanks you!

Code:
#define log(%0) floatlog(%0, 2.7182818)

Last edited by KiLLeR.; 09-24-2017 at 15:59.
KiLLeR. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-24-2017 , 15:08   Re: Exponential function
Reply With Quote #9

Quote:
Originally Posted by KiLLeR. View Post
Thanks you!

Code:
#define log(%0) floatlog(2.7182818, %0)
The base is the second argument, not the first.
__________________
fysiks is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-24-2017 , 16:03   Re: Exponential function
Reply With Quote #10

Yeah, you are true, actually I have figured out how to solve this right before your post, just decided to give it as solution for someone another looking and I make a mistake cuz hurry.
Edited!

Last edited by KiLLeR.; 09-24-2017 at 16:04.
KiLLeR. 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 04:32.


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