Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/cube.sgml`
3d946276d390975c8d3ab0356b11cf8e24f9e8d2a469ecbd0000000100000fa0
 automatically swap values if needed to create a uniform
   <quote>lower left &mdash; upper right</quote> internal representation.
   When the corners coincide, <type>cube</type> stores only one corner
   along with an <quote>is point</quote> flag to avoid wasting space.
  </para>

  <para>
   White space is ignored on input, so
   <literal>[(<replaceable>x</replaceable>),(<replaceable>y</replaceable>)]</literal> is the same as
   <literal>[ ( <replaceable>x</replaceable> ), ( <replaceable>y</replaceable> ) ]</literal>.
  </para>
 </sect2>

 <sect2 id="cube-precision">
  <title>Precision</title>

  <para>
   Values are stored internally as 64-bit floating point numbers. This means
   that numbers with more than about 16 significant digits will be truncated.
  </para>
 </sect2>

 <sect2 id="cube-usage">
  <title>Usage</title>

  <para>
   <xref linkend="cube-operators-table"/> shows the specialized operators
   provided for type <type>cube</type>.
  </para>

  <table id="cube-operators-table">
   <title>Cube Operators</title>
    <tgroup cols="1">
     <thead>
      <row>
       <entry role="func_table_entry"><para role="func_signature">
        Operator
       </para>
       <para>
        Description
       </para></entry>
      </row>
     </thead>

     <tbody>
      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <type>cube</type> <literal>&amp;&amp;</literal> <type>cube</type>
        <returnvalue>boolean</returnvalue>
       </para>
       <para>
        Do the cubes overlap?
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <type>cube</type> <literal>@&gt;</literal> <type>cube</type>
        <returnvalue>boolean</returnvalue>
       </para>
       <para>
        Does the first cube contain the second?
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <type>cube</type> <literal>&lt;@</literal> <type>cube</type>
        <returnvalue>boolean</returnvalue>
       </para>
       <para>
        Is the first cube contained in the second?
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <type>cube</type> <literal>-&gt;</literal> <type>integer</type>
        <returnvalue>float8</returnvalue>
       </para>
       <para>
        Extracts the <parameter>n</parameter>-th coordinate of the cube
        (counting from 1).
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <type>cube</type> <literal>~&gt;</literal> <type>integer</type>
        <returnvalue>float8</returnvalue>
       </para>
       <para>
        Extracts the <parameter>n</parameter>-th coordinate of the cube,
        counting in the following way: <parameter>n</parameter> = 2
        * <parameter>k</parameter> - 1 means lower bound
        of <parameter>k</parameter>-th dimension, <parameter>n</parameter> = 2
        * <parameter>k</parameter> means upper bound of
        <parameter>k</parameter>-th dimension.  Negative
        <parameter>n</parameter> denotes the inverse value of the corresponding
        positive coordinate.  This operator is designed for KNN-GiST support.
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <type>cube</type> <literal>&lt;-&gt;</literal> <type>cube</type>
        <returnvalue>float8</returnvalue>
       </para>
       <para>
        Computes the Euclidean distance between the two cubes.
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <type>cube</type> <literal>&lt;#&gt;</literal> <type>cube</type>
        <returnvalue>float8</returnvalue>
       </para>
       <para>
        Computes the taxicab (L-1 metric) distance between the two cubes.
       </para></entry>
  

Title: Cube Data Type Operators and Precision
Summary
The cube data type has various operators for overlap, containment, and distance calculations between cubes, including overlap, containment, and Euclidean and taxicab distances. The type also has operators for extracting coordinates and handling KNN-GiST support. The values are stored internally as 64-bit floating point numbers, which can lead to truncation of numbers with more than 16 significant digits. The operators provided include && for overlap, @> and <@ for containment, -> and ~> for coordinate extraction, <-> for Euclidean distance, and <#> for taxicab distance.