Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Interesting Challenge
Message
From
31/08/1999 06:53:44
 
 
To
30/08/1999 22:29:59
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00259328
Message ID:
00259573
Views:
13
Hi Erik,

>>>Write a function to calculate the square root of a number to a given number of decimal places. (Yes. I know, VFP has the SQRT function, but what would you do without it?)

Hows this then, it needs some tweaking:
lparam n2square, ndps
nresult = 0
for ndp =0 to ndps
	do while (nresult + 10^(-1*ndp))^2 < n2square
		nResult = nresult + 10^(-1*ndp)
	enddo
endfor
?nResult
You'll need some validation lines of course (n2Sqaure>=0.....), but I think thats the jist of it.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform