PBDR.COM

About   -   Contact   -   Purchase   -   Search   -   What's New

 

Last Updated 09 June, 2007

Taking Roots
This is either something we do after prolonged periods of sitting at the PC or the process of calculating the squared or cubed root, etc. of a value. As VB has no built in nth root functionaility, to take a root use:
	sngRootValue = sngNumber ^ (1 / root)

For example, the cubed root of X is:

	sngRootValue = X ^ (1 / 3)

and the squared root of X is:

	sngRootValue = X ^ (1 / 2)

E.g. where X is 64,  X ^ (1/3)  will return 4

Note: attempting to take the squared root (or any root where the root is an even number) of a negative number will return an error. Basically this is because a squared root reverses the process of a squared value and squared values can only be positive. Just error check code to trap negative values of X prior to executing the example above.

 

Top of Page

Legal Notice

© Ken Howe 2006