In a mathematical context, it's quite common to hear mathematicians
making claims like "the reals are a superset of the rationals".
Just to make it clear, I did not say "real" I said "float". There is
a difference, and I was *NOT* making a direct appeal to any special
mathematics outside the scope of the C language. The set of integers,
their properties, and operations in the *C LANGUAGE* are directly
translatable into floating point (floats or doubles, but obviously I
am interested in doubles here) in the *C LANGUAGE* with the relevant
difference being that the floating point formats can encode different
sizes.
*Richard* expanded the discussion beyond the topic by making blanket
statements about integers that were just wrong. I took the
invitation, kept the discussion narrowed on the topic integers in the
C language, but beyond what is in stdint.h and demonstrated Richard's
error *WITHOUT* expanding the context. If the extension to floating
point bothers you, then ask yourself why EOF gets tacked onto the
output of fgetc() by extending from unsigned chars to ints. Extending
types into other types, is a standard practice in C.
Except they're not; the rationals are equivalence classes over ordered
pairs of integers, and the reals are sets of rationals[1], so no
rational number can possibly be a real number. This doesn't keep it
from being understood as "the rationals are isomorphic to a subset of
the reals", for both the person making the claim and the person hearing
it.
Uh ... its not just an isomorphism, its a bijection complete with all
the operations. They are indistinguishable. The core definitions/
axioms for integers are *satisfied* by the integer subset of the
reals. Claiming they are different is like claiming C doesn't have a
stack. It helps if you think of axioms as properties, not as private
wells from which its special manna becomes magically branded by those
axioms. Whatever, this is *actually* (uncontroversially for once) off
topic; try sci.math .
It seems to have been clear (to everybody but you) that the original
claim was intended to be taken this way, and not to claim that the
representation is identical.
His response is actually quite sad. Knowing that you can have this
extended (if not exactly convenient) integer implementation in C is
kind of useful at times when 32 bits just isn't enough, but you need
more portability that systems that implement 64 bits. He seems dead
set against acknowledging this fact. Perhaps restricting himself to
the C standard just isn't enough; he's got to restrict himself even
more.
[...] It turns out that even then the claim is
wrong (division breaks the isomorphism, and on most implementations
it's trivial to find an integer type and a floating point type such
that the floating point type can't even represent all the values that
the integer type can), but the difference in representation is
irrelevant to that.
I'm not making an argument about representation. Go back through this
thread and notice that I make specific mention of the modf()
function. This allows you to implement integer division and modulo on
floating point numbers. In other words, you have a *true* integer in
floating point implementation in C, and you need not go any further
than the standard library.