Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

## Square Root

Former Community Member
Anyone know how to do a square root in either Javascript or FormCalc?
4 Replies

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

var myvalue = SOMobject.rawValue;

var my_squareroot = Math.sqrt(myvalue);

Former Community Member
Thanks! That worked perfectly.

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????

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.