Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You probably knew this, but you <strong>can</strong> make literal floats/long doubles</p> <pre><code> float f = 4.0f; long double f = 4.0l; </code></pre> <p>Double is the default because thats what most people use. Long doubles may be overkill or and floats have very bad precision. Double works for almost every application.</p> <p>Why the naming? One day all we had was 32 bit floating point numbers (well really all we had was fixed point numbers, but I digress). Anyway, when floating point became a popular feature in modern architectures, C was probably the language dujour then, and the name "float" was given. Seemed to make sense. </p> <p>At the time, double may have been thought of, but not really implemented in the cpu's/fp cpus of the time, which were 16 or 32 bits. Once the double became used in more architectures, C probably got around to adding it. C needed something a name for something twice the size of a float, hence we got a double. Then someone needed even more precision, we thought he was crazy. We added it anyway. The name quadtuple(?) was overkill. Long double was good enough, and nobody made a lot of noise.</p> <p>Part of the confusion is that good-ole "int" seems to change with the time. It used to be that "int" meant 16 bit integer. Float, however, is bound to the <a href="http://en.wikipedia.org/wiki/IEEE_754" rel="noreferrer">IEEE std</a> as the 32-bit IEEE floating point number. For that reason, C kept float defined as 32 bit and made double and long double to refer to the longer standards.</p>
 

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