Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are the first 32 bits of the fractional part of this float?
    text
    copied!<p>I am looking at the following <a href="http://en.wikipedia.org/wiki/SHA-2#SHA-256_.28a_SHA-2_variant.29_pseudocode" rel="noreferrer">SHA256 pseudocode</a> on wikipedia.</p> <p>Specifically, I am looking at the following section.</p> <pre><code>//Initialize variables //(first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19): h0 := 0x6a09e667 </code></pre> <p>I am trying to figure out how h0 was generated. I know from the comment that this should be the fractional part of the square root of 2. I believe I can get the fractional part of the square root of 2 by typing the following. All the following code is from the python repl.</p> <pre><code>&gt;&gt;&gt; math.modf(math.sqrt(2))[0] 0.41421356237309515 </code></pre> <p>At the top of the file it states that the declaration of all constants are Big Endian. I know that my environment is Small Endian because I type.</p> <pre><code>&gt;&gt;&gt; import sys &gt;&gt;&gt; sys.byteorder 'little' </code></pre> <p>So, according to my manual manipulation of the hex value in h0, the Little Endian representation should be 0x67e6096a.</p> <pre><code>&gt;&gt;&gt; int(0x67e6096a) 1743128938 </code></pre> <p>And I am stuck. I have tried various manipulations, but non of them end up with this result. I do not know how to get the first 32 bits of the fractional part of a floating point number. I know that somehow my 0.41421356237309515 (float) result can be transformed into 1743128938 (int), but I really have no idea how. What are the steps necessary to get the first 32 bits of the fractional part of a floating point number? Python answers only please.</p> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload