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?

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())

  • 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! – Jay Cummins Jan 9 at 13:41
  • 1
    @a_horse funny that the |/ operator has lower precedence than / an *. – ypercubeᵀᴹ Jan 9 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. – Ross Presser Jan 17 at 4:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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