Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: AntyMan on July 22, 2014, 12:08:05 pm
-
How exponentation?? I write code:
However, I do not know how you can magnify, for example, 2(a)^0.06(b)
function Exponentation(a, b: integer): integer;
var i: integer;
begin
for i := 1 to b-1 do begin
a:= (a*a);
end;
result := a;
end;
- does not work
exp((a)*b) - does not work
a^b - does not work
-
why
result := NUM;
?
did you mean
result := a;
?
-
yes, sory my bad :P
-
But I can only exacerbate the integers(5^2), but how to exacerbate decimal numbers(5^0,06)?
-
Firstly, your Exponentation(5, 3) gives result = 625, nice math guy, very very nice..
Secondly, here u go
//function made in 5 minutes, I don't take any responsibility for this
//5^(0.06)=5^(6/100) //math is amazing
//a=5, b=6, c=100;
function DontUseMeILagLikeHellAndUseStupidestWayEver(a, b, c: integer): double;
var
fuckinbignumber, areudominik: integer;
wherethefuckisendofthis, yesiamdominik: double;
begin
areudominik:=a;
for fuckinbignumber:=1 to b-1 do begin
a:=(a*areudominik);
end;
result:=1;
repeat
result:=result+0.0001; //0.0001 is resolution (or lagometer for dumbs)
yesiamdominik:=result;
wherethefuckisendofthis:=result;
for fuckinbignumber:=1 to c-1 do begin
wherethefuckisendofthis:=(wherethefuckisendofthis*yesiamdominik);
end;
until a<wherethefuckisendofthis;
result:=result-0.0001; //or maybe not do this? suit yourself
end;
-
My function does literally, what is yours and is much more efficient.
I do not want function counting:
(http://i57.tinypic.com/2j1psh4.png) = 25
I want function counting:
(http://i58.tinypic.com/vq1dt5.png) = 1,03271242
EDIT:
I need it to formula ELO: (http://en.wikipedia.org/wiki/Elo_rating_system)
Round(50/1+Round(Exponentation(10, ((strtoint(PlayerStats[Killer].Points)-strtoint(PlayerStats[Victim].Points))/1000))));
(http://www.philophildesign.de/statsrscs/images/elo.png)
-
1. Your function isn't exponentation even. Do u know what is result of 5^3? It's 125, NOT FUCKING 625 LOL
2. Your function is completely useless -> for i := 1 to 0.02-1 do begin -> nice try
3. My function gives you 1.0327 as result, I think it's quite accurate, don't you?
-
Hello dominikk. I see your translator taught you a new word. Excabertation is something entirely different though. ;D
/dies laughing
-
But power may fall out me from 1 to zero after the decimal point as many as 4, additionally your function terribly lags. We/I must need Shoozza to add this function in 1.7!
-
Add this function?
Grab some book finally and learn it from the scratch man! These new topics are mostly about basic things which aren't much related to soldat/scriptcore.
Google is your best friend and use search function here. But all this will be useless if you don't use that thing in your head.
-
But power may fall out me from 1 to zero after the decimal point as many as 4, additionally your function terribly lags.
Name of my function explains everything.
-
Add this function?
Grab some book finally and learn it from the scratch man! These new topics are mostly about basic things which aren't much related to soldat/scriptcore.
Google is your best friend and use search function here. But all this will be useless if you don't use that thing in your head.
I read and:
While:
Function Exp(X : Real) : Real;
Function Ln(X : Real) : Real;
do not work!
So does not work:
exp(y*ln(x))
-
It should fix the lag problems or even your all problems(idk):
const
precision = 6;
// a = 5, b = 2 => result = 25
function WowSuchASpeed(a: double; b: integer): double;
var
c: double;
begin
if b = 0 then result := 1
//else if b = 1 then result := a
else if b mod 2 = 1 then result := WowSuchASpeed(a, b-1) * a
else begin
c := WowSuchASpeed(a, b div 2);
result := c * c;
end;
end;
// a = 25, b = 100 => result = 1,032712
function WowItsEvenFaster(a: double; b: longint): double;
var
l, r, s, p: int64;
AlgorithmsAreSoEZ: double;
begin
p := round(WowSuchASpeed(10, precision));
l := 0;
r := p;
while(l<r) do begin
s := (l+r) div 2;
AlgorithmsAreSoEZ := s;
if WowSuchASpeed(AlgorithmsAreSoEZ, b) > a then r := s
else l := s + 1;
end;
result := l-1;
l := 0;
r := p-1;
while(l<r) do begin
s := (l+r) div 2;
AlgorithmsAreSoEZ := s;
AlgorithmsAreSoEZ := AlgorithmsAreSoEZ / p;
AlgorithmsAreSoEZ := AlgorithmsAreSoEZ + result;
if WowSuchASpeed(AlgorithmsAreSoEZ, b) > a then r := s
else l := s + 1;
end;
AlgorithmsAreSoEZ := l - 1;
AlgorithmsAreSoEZ := AlgorithmsAreSoEZ / p;
result := result + AlgorithmsAreSoEZ;
end;
-
But I do not want:
WowSuchASpeed(a: double; b: integer): double;
(http://i57.tinypic.com/2j1psh4.png), (http://i59.tinypic.com/1052qtc.png)
I want to:
WowSuchASpeed(a: integer; b: double): double;
(http://i58.tinypic.com/vq1dt5.png) or (http://i61.tinypic.com/w8qr85.png) or (http://i57.tinypic.com/1illp3.png) or etc.
-
Use it like that:
WowItsEvenFaster(WowSuchASpeed(5, 2), 100);
-
Ok but I have to write a large piece code to check whether I have to give 10 or 100 or 1000 etc because, to I have strpos
and to copy the first number after zero (100,00023) I must WowItsEvenFaster(WowSuchASpeed(10, 2), 1000);
EDIT:
Can you simplify your amazing function?
This is useful, probably more than one.