[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [SCICOMP] algoritme til pow(float, float);



>>>>simpel algoritme der kan beregne x^(1/5)

Denne algorithme beregner omtrent et bit per iteration.
Inputs <1 eller >10E5 bliver ikke behandlet rigtig.

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript1.2">
<!-- Hide from old browsers
function calculate (number)
{
	var a=1, b=10, c=(a+b)/2, d;
	do {
		d=c; c*=c;
		if (c*c*d > number)
			b=d;
		else
			a=d;
		c=(a+b)/2;
	} while(d!=c);
	return c;
}
// end hide from old browsers --> 
</SCRIPT>
</HEAD>
Calculates pow(x, 0.2)<BR>
<FORM NAME="hello">
<INPUT TYPE="text" NAME="num" SIZE="40" VALUE="5">
<INPUT TYPE="button" NAME="b4" VALUE="calc" SIZE="40"
onClick="document.hello.num.value=calculate(document.hello.num.value)">
</FORM>
</HTML>

Hilsen, Hans-Christian Stadler


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:34 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *