Author Topic: Exponentation ?...?  (Read 2192 times)

0 Members and 1 Guest are viewing this topic.

Offline AntyMan

  • Major(1)
  • Posts: 31
Exponentation ?...?
« 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)
Code: [Select]
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
« Last Edit: July 23, 2014, 01:11:25 pm by AntyMan »

Offline Shoozza

  • Retired Soldat Developer
  • Veteran
  • ******
  • Posts: 1632
  • Soldat's Babysitter
    • Website
Re: Exponentation ?...?
« Reply #1 on: July 22, 2014, 12:45:54 pm »
why
  result := NUM;
?

did you mean
  result := a;
?
Rules
Tools: ARSSE - SARS - SRB - chatMod

Offline AntyMan

  • Major(1)
  • Posts: 31
Re: Exponentation ?...?
« Reply #2 on: July 22, 2014, 02:36:06 pm »
yes, sory my bad :P

Offline AntyMan

  • Major(1)
  • Posts: 31
Re: Exponentation ?...?
« Reply #3 on: July 23, 2014, 06:16:30 am »
But I can only exacerbate the integers(5^2), but how to exacerbate decimal numbers(5^0,06)?
« Last Edit: July 23, 2014, 06:24:21 am by AntyMan »

Offline kicikici

  • Soldier
  • **
  • Posts: 180
Re: Exponentation ?...?
« Reply #4 on: July 23, 2014, 08:56:54 am »
Firstly, your Exponentation(5, 3) gives result = 625, nice math guy, very very nice..

Secondly, here u go

Code: [Select]
//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;
Classic banana

Offline AntyMan

  • Major(1)
  • Posts: 31
Re: Exponentation ?...?
« Reply #5 on: July 23, 2014, 01:19:11 pm »
My function does literally, what is yours and is much more efficient.
I do not want function counting:
= 25
I want function counting:
= 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))));


« Last Edit: July 23, 2014, 01:27:18 pm by AntyMan »

Offline kicikici

  • Soldier
  • **
  • Posts: 180
Re: Exponentation ?...?
« Reply #6 on: July 23, 2014, 02:56:43 pm »
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?
Classic banana

DarkCrusade

  • Guest
Re: Exponentation ?...?
« Reply #7 on: July 23, 2014, 03:08:24 pm »
Hello dominikk. I see your translator taught you a new word. Excabertation is something entirely different though. ;D

/dies laughing

Offline AntyMan

  • Major(1)
  • Posts: 31
Re: Exponentation ?...?
« Reply #8 on: July 23, 2014, 03:57:36 pm »
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!

Offline Moroes

  • Soldier
  • **
  • Posts: 165
    • Soldat-Game.eu
Re: Exponentation ?...?
« Reply #9 on: July 24, 2014, 12:06:54 am »
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.

Offline kicikici

  • Soldier
  • **
  • Posts: 180
Re: Exponentation ?...?
« Reply #10 on: July 24, 2014, 01:18:23 am »
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.
Classic banana

Offline AntyMan

  • Major(1)
  • Posts: 31
Re: Exponentation ?...?
« Reply #11 on: July 24, 2014, 09:42:54 am »
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))
« Last Edit: July 24, 2014, 09:45:07 am by AntyMan »

Offline Nedi

  • Major(1)
  • Posts: 47
Re: Exponentation ?...?
« Reply #12 on: July 25, 2014, 04:17:57 am »
It should fix the lag problems or even your all problems(idk):
Code: [Select]
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;
« Last Edit: July 25, 2014, 04:21:04 am by Nedi »

Offline AntyMan

  • Major(1)
  • Posts: 31
Re: Exponentation ?...?
« Reply #13 on: July 25, 2014, 09:43:43 am »

But I do not want:
WowSuchASpeed(a: double; b: integer): double;
,
I want to:
WowSuchASpeed(a: integer; b: double): double;
or or or etc.

Offline Nedi

  • Major(1)
  • Posts: 47
Re: Exponentation ?...?
« Reply #14 on: July 25, 2014, 10:45:53 am »
Use it like that:
Code: [Select]
WowItsEvenFaster(WowSuchASpeed(5, 2), 100);

Offline AntyMan

  • Major(1)
  • Posts: 31
Re: Exponentation ?...?
« Reply #15 on: July 25, 2014, 11:27:31 am »
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.
« Last Edit: July 25, 2014, 11:32:54 am by AntyMan »