pages tagged never
http://wok.oblomov.eu/tag/never/
wok's neverikiwikiSat, 10 Oct 2015 20:55:08 +0200Poi poi, mai maihttp://wok.oblomov.eu/tecnologia/poi-poi-mai-mai/
http://wok.oblomov.eu/tecnologia/poi-poi-mai-mai/
ieee754infinitylatermathmathmlnanneverstandardtimeTue, 11 Aug 2015 18:42:52 +02002015-10-10T18:55:08Z<div class="aside">
<p>Note: this article
makes use of <a href="http://en.wikipedia.org/wiki/MathML">MathML</a>, the standard XML markup for math formulas.
Sadly, this is not properly supported on some allegedly ‘modern’ and
‘feature-rich’ browsers. If the formulas don't make sense in your
browser, consider reporting the issue to the respective developers
and/or switching to a standard-compliant browser.</p>
</div>
<p>For the last three decades or so, non-integer numbers have been
represented on computers following (predominantly) the floating-point
standard known as <a href="http://en.wikipedia.org/wiki/IEEE%2D754">IEEE-754</a>.</p>
<p>The basic idea is that each number can be written in what is also known
as engineering or scientific notation, such as <math><mstyle><mn>2.34567</mn><mo>×</mo><msup><mn>10</mn><mn>89</mn></msup></mstyle></math>, where
the <math><mstyle><mn>2.34567</mn></mstyle></math> part is known as the <em>mantissa</em> or <em>significand</em>, <math><mstyle><mn>10</mn></mstyle></math> is
the base and <math><mstyle><mn>89</mn></mstyle></math> is the exponent. Of course, on computers <math><mstyle><mn>2</mn></mstyle></math> is more
typically used as base, and the mantissa and exponent are written in
binary.</p>
<p>Following the IEEE-754 standard, a floating-point number is encoded
using the most significant bit as sign (with 0 indicating a positive
number and 1 indicating a negative number), followed by some bits
encoding the exponent (in <a href="http://wok.oblomov.eu/tag/never/compnum/intmath#biased">biased</a>
representation), and the rest of the bits to encode the fractional part
of the mantissa (the leading digit of the mantissa is assumed to be 1,
except for denormals in which case it's assumed 0, and is thus always
implicit).</p>
<p>The biased representation for the exponent is used for a number of
reasons, but the one I care about here is that it allows “special
cases”. Specifically, the encoded value of 0 is used to indicate the
number 0 (when the mantissa is also set to 0) and denormals (which I
will not discuss here). An exponent with all bits set to 1, on the
other hand, is used to represent <math><mstyle><mo>∞</mo></mstyle></math> (when the mantissa is set to 0)
and special values called “Not-a-Number” (or <a href="http://en.wikipedia.org/wiki/NaN">NaN</a> for short).</p>
<p>The ability of the IEEE-754 standard to describe such special values
(infinities and NaN) is one of its most powerful features, although
often not appreciated by programmers. Infinity is extremely useful to
properly handle functions with special values (such as the trigonometric
tangent, or even division of a non-zero value by zero), whereas NaNs are
useful to indicate that somewhere an invalid operation was attempted
(such as dividing zero by zero, or taking the square root of a negative
number).</p>
<hr />
<p>Consider now the proverb “later means never”. The Italian proverb with
the same meaning (that is, procrastination is often an excuse to not do
things <em>ever</em>) is slightly different, and it takes a variety of forms
(«il poi è parente del mai», «poi è parente di mai», «poi poi è parente
di mai mai») which basically translate to “later is a relative of
never”.</p>
<p>What is interesting is that if we were to define “later” and “never” as
“moments in time”, and assign numerical values to it, we could
associate “later” with infinity (we <em>are</em> procrastinating, after all),
while “never”, which cannot actually be a “moment in time” (it <em>is</em>
never, after all) would be … not a number.</p>
<p>(Actually, it's also possible to consider “later” as being indefinite
in time, and thus not a (specific) number, and “never” having an
infinite value. Or to have both later and never be not numbers. But
that's fine, it still works!)</p>
<p>So as it happens, both later and never can be represented in the
IEEE-754 floating-point standard, and they share the special exponent
that marks non-finite numbers.</p>
<p>Later, it would seem, is indeed a relative of never.</p>