Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Square Root

Avatar

Not applicable
Anyone know how to do a square root in either Javascript or FormCalc?
4 Replies

Avatar

Level 5
it is simple in JS. Here you go....

var myvalue = SOMobject.rawValue;

var my_squareroot = Math.sqrt(myvalue);

Avatar

Not applicable
Thanks! That worked perfectly.

Avatar

Level 2
I am trying to set up a Standard Deviation calculation using FormCalc. Here is what I have so far, because it does not recognise the ^ to raise to a power I just multiplied a part by itself. Any suggestions as to how to get this to do the square root?



(((((WaterGlc1-WaterGlcAvg)*(WaterGlc1-WaterGlcAvg))+((WaterGlc2-WaterGlcAvg)*(WaterGlc2-WaterGlcAvg))+((WaterGlc3-WaterGlcAvg)*(WaterGlc3-WaterGlcAvg)))/2)^0.5)



I am searching all the hardcopy references I have at my disposal and nothing has even come close as of yet. Can someone please help????

Avatar

Level 7
If you noticed in response of the square root, there are special funcitons for doing advanced math in JavaScript and FormCalc. The JavaScirpt's advance funcitons are described in the Mozilla JavaScript documentaion and FormCalc's is partially done in the included scriptig references.



JavaScript:



Math.pow(fBaseNumber, fExponent)



FormCalc:



Pow(fBaseNumber, fExponent)



The exponent function and square root are both undocumented functions in FormCalc. The FormCalc funciton for the square root is "Sqrt(fValue)".



There is also an average function for both JavaScript and FormCalc.