[Plugin] CMath Library - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (
https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] CMath Library (
/showthread.php?tid=640194)
CMath Library -
Jelly23 - 29.08.2017
• CMath Library
I released this plugin well before in Portuguese section before my account removal but didn't do it here until now, this was pretty much my first plugin release back then.
This plugin allows you to use some of CMath library's mathematical functions, few aren't included since they already exist.
Reference: Here
Functions:
Code:
native Float:cosh(Float:x);
native Float:sinh(Float:x);
native Float:tanh(Float:x);
native Float:acosh(Float:x);
native Float:asinh(Float:x);
native Float:atanh(Float:x);
native Float:exp(Float:x);
native Float:frexp(Float:x, &exp);
native Float:ldexp(Float:x, exp);
native Float:log10(Float:x);
native Float:modf(Float:x, &Float:intpart);
native Float:exp2(Float:x);
native Float:expm1(Float:x);
native ilogb(Float:x);
native Float:log1p(Float:x);
native Float:log2(Float:x);
native Float:logb(Float:x);
native Float:scalbn(Float:x, exp);
native Float:cbrt(Float:x);
native Float:hypot(Float:x, Float:y);
native Float:tgamma(Float:x);
native Float:lgamma(Float:x);
native Float:remquo(Float:numer, Float:denom, ");
native Float:copysign(Float:x, Float:y);
native Float:fdim(Float:x, Float:y);
native Float:fmax(Float:x, Float:y);
native Float:fmin(Float:x, Float:y);
Examples:
PHP Code:
//Example: native Float:frexp(Float:x, &exp);
main()
{
new Float:param = 8.0, Float:result, n;
result = frexp (param , n);
printf ("%f = %f * 2^%d\n", param, result, n);
}
//Output: 8.000000 = 0.500000 * 2^4
PHP Code:
//Example: native Float:remquo(Float:numer, Float:denom, ");
main()
{
new Float: numer = 10.3, Float:denom = 4.5, Float:result, quot;
result = remquo (numer, denom, quot);
printf ("numerator: %f", numer);
printf ("denominator: %f", denom);
printf ("remainder: %f", result);
printf ("quotient: %d", quot);
}
/*
Output:
numerator: 10.300000
denominator: 4.500000
remainder: 1.300000
quotient: 2
*/
-Thanks to Dayvison_ for linux binary.
Download
Github
Re: CMath Library -
C4rtm4n - 30.08.2017
Good Plugin
Re: CMath Library -
NathanT - 01.09.2017
Good work, it is very interesting adding practical functions of C++ to PAWN.