Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Note that even before you permute the words, all of the following denote the same type:</p> <ul> <li><code>long</code></li> <li><code>long int</code></li> <li><code>signed long int</code></li> <li><code>signed long</code></li> </ul> <p>With permutations, you could have:</p> <pre><code>long l0; long int l1; int long l2; signed long int l3; signed int long l4; long signed int l5; long int signed l6; int signed long l7; int long signed l8; signed long l9; long signed lA; </code></pre> <p>Most sane people, most of the time, simply write <code>long</code> to denote this type.</p> <p>Your actual question is about when to use <code>long int</code> and when to use <code>int</code>. Technically, the range of values guaranteed by <code>int</code> is ±32,767 (or ±(2<sup>15</sup>-1)). If you need values bigger than that, you should use <code>long</code>. However, you often find that <code>int</code> has a range of ±(2<sup>31</sup>-1) (more or less). Sometimes, the range of <code>long</code> is the same as <code>int</code> (32-bit systems; 64-bit Windows); then the main reason for using <code>long</code> or <code>int</code> is to match the interface to a particular API (because the types are still distinct, even if they support the same range). Sometimes, the range of <code>long</code> is ±(2<sup>63</sup>-1) (64-bit systems apart from 64-bit Windows); then you'd use <code>long</code> if you needed a range bigger than <code>int</code>. However, you might also consider using the 'portable' types from <code>&lt;inttypes.h&gt;</code> or <code>&lt;stdint.h&gt;</code> such as <code>int32_t</code> and <code>int64_t</code> instead. However, if the API uses a different type, you should probably use the API's type.</p> <p>If you intended to ask about when to use <code>long</code> and <code>long int</code>, then it is a matter of taste. I'd use plain <code>long</code> without any qualms. Unless there was a compelling reason for symmetry with some other declaration, I'd not use anything else.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload