Thanks for your answers feyd
feyd wrote:hex, decimal, and octal, like I said previously, are all native number formats. When parsed, they are
immediately converted to their (in-memory) binary form.
Thanks for letting me know this native format concept which I am not aware of earlier
feyd wrote:That's not normally possible. Are you sure a isn't a string? Javascript will generally do string work if any of the operands in an expression is a string unless implicit conversion can be performed.
This is where 'a' comes from
Code: Select all
for (var t=0; t<80; t++) {
var s = Math.floor(t/20); // seq for blocks of 'f' functions and 'K' constants
T = (ROTL(a,5) + f(s,b,c,d) + e + K[s] + W[t]) & 0xffffffff;
e = d;
d = c;
c = ROTL(b, 30);
b = a;
a = T;
}
// 4 - compute the new intermediate hash value
H0 = (H0+a) & 0xffffffff; // note 'addition modulo 2^32'
H1 = (H1+b) & 0xffffffff;
H2 = (H2+c) & 0xffffffff;
H3 = (H3+d) & 0xffffffff;
H4 = (H4+e) & 0xffffffff;
feyd wrote:numbers are always signed in Javascript. The last bit of a 32 bit number is the sign bit. Since you are using the bitwise and operator with a full 32 bit numeric, a negative result would indicate that the most significant bit was set.
Can a negative integer be represented in hex?
4. I have tried to debug this stmt.
Code: Select all
H0 = (H0+a) & 0xffffffff; // note 'addition modulo 2^32'
The inputs:
H0 = 0x67452301;
a = 1112808245;
Binary equivalents:
1111000001110001110000010111000010101010100010111111111100110101
11111111111111111111111111111111
Subjected to AND logical operation resulted:
10101010100010111111111100110101
Equivalent dec for the result :
2861301557 which is not equal to the result it gave (-1449574858)