my friend coded a root function ...
not for speed . actully i think its very slow ..
but very useful you can calculate the 19 root of 2.45
and things like that
here is the code . note he coded it in pascal
bye
eko
not for speed . actully i think its very slow ..
but very useful you can calculate the 19 root of 2.45
and things like that
here is the code . note he coded it in pascal
rogram root;
var
num:real;
m:integer;
function hez(x:real; n:integer):real;
var
i:integer;
s:real;
begin
s:=1;
for i:=1 to n do
s:=s*x;
hez:=s;
end;
function rot(num:real; m:integer):real;
var
t,s:real;
i,j:integer;
begin
s:=0;
repeat
s:=s+1
until hez(s,m)>trunc(num);
s:=s-1;
i:=0;
t:=0;
repeat
inc(i);
j:=0;
repeat
inc(j);
t:=s+j/hez(10,i);
until hez(t,m)>=num;
j:=j-1;
s:=s+(j/hez(10,i));
until (i=10) or (hez(s,m)=num);
rot:=s;
end;
begin
writeln('enter number');
readln(num);
writeln('enter which root');
readln(m);
writeln('root is: ',rot(num,m):0:10);
writeln(rot(num,m):0:10,' ^ ',m,' = ',hez(rot(num,m),m):0:5);
readln;
end.
bye
eko
Originally posted by eko
actully i think its very slow
What do you have to base this on?
actully i think its very slow
Have you tried to code the algo in asm?
Well, I think in sake of respect for this forum, coders who are not able to code algo in asm could at least post asm translation from compiler. Some times looking at posts I get impression that I lost
in Inet and get to wrong place.
in Inet and get to wrong place.
Some times looking at posts I get impression that I lost in Inet and get to wrong place.
I will help you translate eko - post what you have, and we will work to speed it up.
What do you have to base this on?
nothing .. i had done disassmbler to what turbo pascal produced
i'm wondering how they do floating point math? i didnt saw one command from the fpu ?
Well, I think in sake of respect for this forum, coders who are not able to code algo in asm could at least post asm
]
maybe .. my friend is not one of the members
I will help you translate eko - post what you have, and we will work to speed it up.
coool
:alright:
the function hez does "power of "
do you have faster way of doing power of ?
begin
s:=0;
repeat
s:=s+1
until hez(s,m)>trunc(num);
this part of the code do use with integer only
so we can do Inthez and fhez
the function hez does "power of "
do you have faster way of doing power of?
maybe .. my friend is not one of the members
You are...
i'm working on a translation
but i'm not very good with the fpu . :(
but i'm not very good with the fpu . :(
That is fine eko - we all must start somewhere.
Like Nike says, "Just do it" - you must start.
Like Nike says, "Just do it" - you must start.
how can i load a 32reg into fpu ?
fld ?
fld ?
You can't load a integer register directly.
; load register EAX into top of FPU stack
push eax
fild DWORD PTR
add esp,4
I would strongly advise reading either some beginner tutorials on the FPU, or the appropriate sections of the Intel manuals. There is a chapter in the first volume of the Intel manuals which outlines the FPU.
; load register EAX into top of FPU stack
push eax
fild DWORD PTR
add esp,4
I would strongly advise reading either some beginner tutorials on the FPU, or the appropriate sections of the Intel manuals. There is a chapter in the first volume of the Intel manuals which outlines the FPU.
hiii i wasnt here for 4 days .. traveled with my girlfriend ... had best TIME :tongue:
i'll continue work on my translation as soon as i get to my computer
bye
eko
i'll continue work on my translation as soon as i get to my computer
bye
eko
EDIT
2nd try
the algo work with accuracy of 11 (and you can add more ) digits after the dot
this example calculate 17th root of 256.2
bye
eko
2nd try
the algo work with accuracy of 11 (and you can add more ) digits after the dot
this example calculate 17th root of 256.2
bye
eko