We were talking about the size of the largest range of integers that can accurately be represented by double-precision floats.

Ah. I see where the confusion arises. However, what I was addressing was how that can be expressed in terms of an n-bit signed integer, saying:

So, for practical purposes a 64-bit IEEE-754 double precision floating point value can act as a 54-bit signed integer (with the usual 2's complement -ve values).

The range of integers that can be represented is, of course, -(2^53)..+(2^53) (inclusive) -- in the sense that there are no gaps between the integers in that range. Outside that range there are gaps, for example ((2^53)+2) exists, but ((2^53)+1) does not. (Lurking inside that range is -0, but we're glossing over that.)

However, we're pretty familiar with the properties of an n-bit signed integer. In those terms, we have a 54-bit signed integer, noting the limitations of this, including:

I think those are the important caveats. (Noting that these days "signed" is implicitly "two's complement".)

I didn't follow what you said in that paragraph, but there's no rounding involved in storing 2**53 in a float.

I couldn't see where I'd talked about storing 2^53 in a float. However, I've updated the posting and hope that has reduced any scope for confusion. If it's still not clear, I'll be happy to keep improving it :-)


(Off topic).

It's reaching back a fair way... the old CDC's used one's complement integers and one's complement reals ! But I doubt any of those are still running.

Does anyone know of a not two's complement machine actual use these days ?

Or, for that matter, not IEEE-754 floating point ?


The C99 standard has a good definition of "Integer types". I have the ISO/IEC 9899:1999 (E) in front of me. I imagine that this refects most people's understanding of integers.

It specifies that the representation of a signed integer comprises a number of "value bits" and a "sign bit". (Leaving aside the optional "padding bits".)

It specifies that the value part represents values in the range 0..((2^M)-1), where M is the number of value bits. This is the value of the integer when the sign bit is zero.

It specifies the value of the integer when the sign bit is one, allowing for sign and magnitude, two's complement and one's complement implementations of negative integers.

The precision is defined to be the number of value bits. The width is defined to be the number of value and sign bits (so is one greater than the precision, for signed integers).

In these terms, the "integer range" of IEEE-754 double floating point format approximates most closely to a sign and magnitude signed integer with 53-bit precision -- but that leaves out -(2^53) as well as +(2^53) !


In reply to Re^9: 64-bit digest algorithms by gone2015
in thread 64-bit digest algorithms by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.