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
``````
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');
writeln('enter which root');
writeln('root is: ',rot(num,m):0:10);
writeln(rot(num,m):0:10,' ^ ',m,' = ',hez(rot(num,m),m):0:5);
end.
``````

bye
eko
Posted on 2002-03-22 10:05:36 by eko
Originally posted by eko
actully i think its very slow
What do you have to base this on?
Have you tried to code the algo in asm?
Posted on 2002-03-22 10:40:58 by bitRAKE
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.
Posted on 2002-03-22 11:09:49 by The Svin

Some times looking at posts I get impression that I lost in Inet and get to wrong place.
:grin: Funny.

I will help you translate eko - post what you have, and we will work to speed it up.
Posted on 2002-03-22 11:30:24 by bitRAKE
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
Posted on 2002-03-22 12:14:32 by eko

the function hez does "power of "
do you have faster way of doing power of?
Powers of two are very easy on integer, and a little harder on FPU. There are a couple of power functions on this board for the FPU.
Posted on 2002-03-22 12:29:30 by bitRAKE
maybe .. my friend is not one of the members

You are...
Posted on 2002-03-22 12:32:11 by The Svin
i'm working on a translation
but i'm not very good with the fpu . :(
Posted on 2002-03-22 12:42:29 by eko
That is fine eko - we all must start somewhere.
Like Nike says, "Just do it" - you must start.
Posted on 2002-03-22 12:47:55 by bitRAKE
how can i load a 32reg into fpu ?
fld ?
Posted on 2002-03-22 13:13:39 by eko
You can't load a integer register directly.

; load register EAX into top of FPU stack
push eax
fild DWORD PTR

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.
Posted on 2002-03-22 13:30:12 by bitRAKE
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
Posted on 2002-03-27 11:53:03 by 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
Posted on 2002-03-29 08:21:16 by eko