6

I'm wondering what pipe slash |/ does in,

SET equal_area_radius = |/area/pi();

The statement works and it definitely changes the value:

SELECT |/125.555/pi(); --  returns: 6.32181918120139
SELECT 125.555/pi();   --  returns: 39.9653977598058

What does the pipe-slash operator |/ do?

0

1 Answer 1

5

The |/ operator calculates the square root

postgres>  select |/16,  sqrt(16);
 ?column? | sqrt
----------+------
        4 |    4
(1 row)

So |/125.555/pi() is equivalent to sqrt(125.555/pi())

3
  • Sure enough--looked at the site where I copied the statement from and they had this: i.imgur.com/5twDykK.png I should have worked that one out. Thanks! Jan 9, 2019 at 13:41
  • 1
    @a_horse funny that the |/ operator has lower precedence than / an *. Jan 9, 2019 at 15:01
  • it makes sense. in math, the radical symbol, which |/ is supposed to suggest, is often used with a long expression underneath it. this would only work if |/ has low precedence. Jan 17, 2019 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.