Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Bare decorations (was ...level 2 datums) - level 2 versus level 3



JP>    How can one specify the set F of level 2 datums of IEEE 754's
JP>    "binary32" datatype in a representation-free way?

JP>  The specification must enable one to answer the question "how many such datums are there?",
JP>  i.e. to find the cardinality of F explicitly -- a boring but valid level 2 question.


Ignoring operations, rounding, exceptions etc., which are not part of the set of datums:

* Level 3:  There is a sign bit, stored as the uppermost bit, with 0 meaning positive and 1 meaning negative.

  Level 2:  There is a sign, which is either positive or negative.


* Level 3:  There is a 7 bit exponent field, stored between the sign bit and the fraction field.
            The exponent is biased, so the leftmost bit is 0 for negative exponents and 1 for zero or positive exponents.
            All zero bits indicates that the value is either a Zero (if the fraction field is all zero bits),
            or a Subnormal (if the fraction field has at least one nonzero bit).
            All one bits indicates that the value is either an Infinity (if the fraction field is all zero bits),
            or a NaN (if the fraction field has at least one nonzero bit).
            Infinities represent both Infinities (eg, from 1./0.) and overflows (eg, from maxfinite+maxfinite).
            Other values represent Normal values with the base 2 exponents 2^-62 to 2^+62.

  Level 2:  For Normal values there is a base 2 exponents 2^-62 to 2^+62.
            For Subnormal values the exponent is 2^-63 or less, and each step lower decreases the precision by one bit.
            The smallest positive nonzero value is 2^(-63-23).
            For Zeros, Infinities and NaNs there is no exponent.
            Infinities represent both conceptual infinities (eg, the result of 1./0.) and overflows (eg, from maxfinite+maxfinite rounded away from zero).


* Level 3:  There is a fraction field, stored as the lower 24 bits.
            The binary point is at the upper end.
            For Normal values the fraction is 25 bits, adjusted (with a corresponding adjustment to the exponent) so the upper bit is a 1.
            For Subnormal values the fraction is 25 bits with the upper bit 0.
            For Normals and Subnormals the upper bit is called the Hidden Bit and is not stored since it is always known.
            For NaNs the fraction distinguishes Quiet from Signaling NaNs and holds a "payload" of 24 bits, at least one being a 1.
            There way to distinguish Quiet versus Signaling NaNs is implementation defined,
            typically based on the uppermost payload bit (but which 0 means and which 1 means differs between implementations).
            For Zeros and Infinities there is no fraction or payload.

  Level 2:  For Normal and Subnormal values there is a fraction.
            For Normal values the fraction is 25 bits, adjusted (with a corresponding adjustment to the exponent) so the upper bit is a 1.
            For Subnormal values the fraction is 25 bits with the upper bit 0.
            For NaNs there is no fraction.  Instead there is a "payload" of 24 bits, at least one being a 1.
            For Zeros and Infinities there is no fraction or payload.


* Level 3:  The representation implies that positive and negative values are symmetrical
            (unlike twos complement integers where the most negative value has no corresponding positive value).
            Positive and negative Zeros are considered equal in value for comparisons and some operations,
            but distinguishable in other operations.

  Level 2:  Positive and negative values are symmetrical.
            Positive and negative Zeros are considered equal in value for comparisons and some operations,
            but distinguishable in other operations.


This should show how one can consider the Level 2 characteristics of an abstract data type without going into all the Level 3 representation details.  It doesn't matter how big the fields are, or what order they're in, or to some extent what values in them mean what, just what the possible representable values are.  In a way, semantics not syntax.

It also shows that you NEED to know some of the Level 3 details to determine parts of the Level 2 abstract data type (eg, that Infinities cannot have payloads - IF 754 had used different exponent field values for NaNs versus Infinities, then Infinities could have had payloads).

Similarly, one needs to understand the Level 3 representation and the Level 2 abstract data type to understand what aspects of the Level 1 mathematical concepts CAN and CANNOT be represented; eg, that Intervals represented via IEEE 754 floating point cannot distinguish the concept "positive infinity" represented by 754 +Infinity from the infinite set of finite values also mapped to the 754 representation +Infinity.  At some point we need to think about whether that makes any of our previous discussions and decisions just wishful thinking.

- Ian McIntosh IBM Canada Lab Compiler Back End Support and Development

----- Forwarded by Ian McIntosh/Toronto/IBM on 10/25/2010 04:37 PM -----


From:

John Pryce <j.d.pryce@xxxxxxxxxxxx>

To:

Ian McIntosh/Toronto/IBM@IBMCA

Date:

10/25/2010 05:33 AM

Subject:

Re: Bare decorations (was ...level 2 datums)





Nate

On 25 Oct 2010, at 06:09, Nate Hayes wrote:

>> It is possible to discuss Level 2 in the abstract, but there is NO way to
>> define a specific Level 2 floating-point or interval datatype without
>> describing it by some sort of formula, which usually amounts to a
>> representation.
>
> I'm sorry, John, but this is not true.
>
> It is done all the time. A good reference is Bertrand Meyer's book on
> object-oriented design where he describes an abstract datatype (ADT) purely
> in mathematical terms by:
>
>   -- its types (i.e., its mathematical sets)
>   -- its functions
>   -- its axioms
>   -- its preconditions (if any)

I have read books on OO design; indeed I consulted one of Grady Booch's while composing that last email. Maybe what's at issue is what my words "amounts to a representation" mean. So I ask you
   How can one specify the set F of level 2 datums of IEEE 754's
   "binary32" datatype in a representation-free way?
The specification must enable one to answer the question "how many such datums are there?", i.e. to find the cardinality of F explicitly -- a boring but valid level 2 question.

John