 # What is the traditional sign for square root?

This is not necessarily a processing question, but I understand that in coding we can make use of operands such as / for divide, * for multiply, ^ for power, is there a predefined operand for squareroot, or is it just traditionally accepted that squareroot is eg ^1/2

Usually you can expect to have a sqrt() function. It might be in a math library. Or yes, you can just do ^(1/2.0).

Quick follow up question I’m writing an evaluation parser, is there a recommendation for one over the other and if so why, or should both be suitable?

1 Like

OK but which is more practical when writing expressions

Let’s say sqrt(9)*2*a+10 or 9^1/2*a+10

Would you have a preference for one over the other or would you not mind so long as it was properly documented. To be fair I could implement both and just have a way to switch between both.

You can also use the double star ** operator like in Python or Ruby for exponentiation. (which is more common that ^ the bitwise XOR operator)

Concerning the sqrt(9) vs 9**(1/2) (note the parenthesis here), it’s semantically the same, it depends on the user and how you clear you want it to be.

Also just for fun, see which is faster in Python:

1 Like