By Jay Cummins


2019-01-09 13:28:10 8 Comments

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?

1 comments

@a_horse_with_no_name 2019-01-09 13:30:41

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

@Jay Cummins 2019-01-09 13:41:30

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!

@ypercubeᵀᴹ 2019-01-09 15:01:26

@a_horse funny that the |/ operator has lower precedence than / an *.

@Ross Presser 2019-01-17 04:09:40

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.

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] What does select * from table where column * 'value'; do?

  • 2019-02-12 09:42:46
  • user172301
  • 61 View
  • 0 Score
  • 2 Answer
  • Tags:   mysql operator

2 Answered Questions

[SOLVED] Compare an hour between two hour columns

1 Answered Questions

2 Answered Questions

[SOLVED] Does the spec permit column-count mismatch on INSERT?

1 Answered Questions

1 Answered Questions

[SOLVED] What does it mean there is multiple sources in a SELECT's "FROM" clause?

  • 2018-01-16 01:40:02
  • user3243135
  • 118 View
  • 0 Score
  • 1 Answer
  • Tags:   postgresql

1 Answered Questions

[SOLVED] && vs ST_Intersects performance

0 Answered Questions

operator class "gin_trgm_ops" does not accept data type tsvector

1 Answered Questions

[SOLVED] What is the purpose of the keyword “||” in PostgreSQL?

  • 2015-06-03 13:58:52
  • Jason
  • 72 View
  • 0 Score
  • 1 Answer
  • Tags:   postgresql

1 Answered Questions

[SOLVED] What does the Postgres <-> operator do?

  • 2014-12-22 13:02:35
  • Villiers Strauss
  • 2662 View
  • 5 Score
  • 1 Answer
  • Tags:   postgresql operator

Sponsored Content