What are the first 32 bits of the fractional part of this float?

后端 未结 3 1264
遇见更好的自我
遇见更好的自我 2021-02-05 21:20

I am looking at the following SHA256 pseudocode on wikipedia.

Specifically, I am looking at the following section.

//Initialize variables
//(first 32 bits          


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 22:24

    1. Use your calculator on Windows to calculate sqrt(2) (1.4142135623730950488016887242097)
    2. Take the decimal part (0.4142135623730950488016887242097)
    3. Multiply by 2^32 (1779033703.9520993849027770600526)
    4. Express the whole part in hex (6A09E667)

    Voila. (Apologies to OP for not doing a Python answer but I hope the method is clear.)

提交回复
热议问题