openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Openexr-devel] 16-bit unsigned integer


From: Florian Kainz
Subject: Re: [Openexr-devel] 16-bit unsigned integer
Date: Mon, 12 Jun 2006 11:55:49 -0700
User-agent: Mozilla Thunderbird 1.0 (X11/20041207)

Luc-Eric Rousseau wrote:
-----Original Message-----
From: Florian Kainz [mailto:address@hidden

There are 15361 different half values values between 0 and 1

How does one calculate that number?


For half numbers, the binary representations of 0.0 and 1.0 are
0000000000000000 and 0011110000000000 respectively.  Interpreted as
integers, the decimal values of these bit patterns are 0 and 15360.
The bit patterns with decimal values 1 through 15359 correspond to
half values that are greater than 0.0 and less than 1.0.
Alltogether there are 15359+2 or 15361 half values that are greater
than or equal to zero, and less than or equal to one.

Florian


-----------

P.S.: Here are a few more details about the representation of
half numbers, copied from the comments in header file half.h:

 Representation of a half:

      Here is the bit-layout for a half number, h:

          15 (msb)
          |
          | 14  10
          | |   |
          | |   | 9        0 (lsb)
          | |   | |        |
          X XXXXX XXXXXXXXXX

          s e     m

      S is the sign-bit, e is the exponent and m is the significand.

      If e is between 1 and 30, h is a normalized number:

                  s    e-15
          h = (-1)  * 2     * 1.m

      If e is 0, and m is not zero, h is a denormalized number:

                  S    -14
          h = (-1)  * 2     * 0.m

      If e and m are both zero, h is zero:

          h = 0.0

      If e is 31, h is an "infinity" or "not a number" (NAN),
      depending on whether m is zero or not.

      Examples:

          0 00000 0000000000 = 0.0
          0 01110 0000000000 = 0.5
          0 01111 0000000000 = 1.0
          0 10000 0000000000 = 2.0
          0 10000 1000000000 = 3.0
          1 10101 1111000001 = -124.0625
          0 11111 0000000000 = +infinity
          1 11111 0000000000 = -infinity
          0 11111 1000000000 = NAN
          1 11111 1111111111 = NAN





reply via email to

[Prev in Thread] Current Thread [Next in Thread]