Java hex calculation
I have the long
value bits
declared like so:
long bits = len*8L;
(304)
System.out.println(bits);
This outputs as 304
If I use the long name bits like so I get 0 & 0 respectively.
System.out.println(bits>>(4*8));
System.out.println(0xFF&(bits>>(4*8)));
If I use the actual number, like so, I get 304 and 48 respectively
System.out.println(304>>(4*8));
System.out.println(0xFF&(304>>(4*8)));
I'm trying to convert this Java to JavaScript but JavaScript gives me 304 and 48 in all scenarios. I need it to match the Java and give values of 0 & 0.
Any ideas?
EDIT
Follow up, just to be clear, I need the JavaScript equivalent to equal 0, mimicking how the Java currently does it (the two examples above that equal 0 won't be changed in what we're developing).
So console.log(0xFF&(bits>>(4*8))) should equal 0, it currently equates to 48
javascript java hex long-integer calculation
add a comment |
I have the long
value bits
declared like so:
long bits = len*8L;
(304)
System.out.println(bits);
This outputs as 304
If I use the long name bits like so I get 0 & 0 respectively.
System.out.println(bits>>(4*8));
System.out.println(0xFF&(bits>>(4*8)));
If I use the actual number, like so, I get 304 and 48 respectively
System.out.println(304>>(4*8));
System.out.println(0xFF&(304>>(4*8)));
I'm trying to convert this Java to JavaScript but JavaScript gives me 304 and 48 in all scenarios. I need it to match the Java and give values of 0 & 0.
Any ideas?
EDIT
Follow up, just to be clear, I need the JavaScript equivalent to equal 0, mimicking how the Java currently does it (the two examples above that equal 0 won't be changed in what we're developing).
So console.log(0xFF&(bits>>(4*8))) should equal 0, it currently equates to 48
javascript java hex long-integer calculation
In Java,304
is anint
, so there is an implicit((4*8)%32)
for the number of bits to shift.bits
is along
, so there is an implicit((4*8)%64)
. JavaScript, I don't know...
– Ken Y-N
Nov 14 '18 at 1:28
1
And to followup on @KenY-N Javascript does all shifts as a 32bit number. So shifting by 32bits is ignored.
– lod
Nov 14 '18 at 1:31
add a comment |
I have the long
value bits
declared like so:
long bits = len*8L;
(304)
System.out.println(bits);
This outputs as 304
If I use the long name bits like so I get 0 & 0 respectively.
System.out.println(bits>>(4*8));
System.out.println(0xFF&(bits>>(4*8)));
If I use the actual number, like so, I get 304 and 48 respectively
System.out.println(304>>(4*8));
System.out.println(0xFF&(304>>(4*8)));
I'm trying to convert this Java to JavaScript but JavaScript gives me 304 and 48 in all scenarios. I need it to match the Java and give values of 0 & 0.
Any ideas?
EDIT
Follow up, just to be clear, I need the JavaScript equivalent to equal 0, mimicking how the Java currently does it (the two examples above that equal 0 won't be changed in what we're developing).
So console.log(0xFF&(bits>>(4*8))) should equal 0, it currently equates to 48
javascript java hex long-integer calculation
I have the long
value bits
declared like so:
long bits = len*8L;
(304)
System.out.println(bits);
This outputs as 304
If I use the long name bits like so I get 0 & 0 respectively.
System.out.println(bits>>(4*8));
System.out.println(0xFF&(bits>>(4*8)));
If I use the actual number, like so, I get 304 and 48 respectively
System.out.println(304>>(4*8));
System.out.println(0xFF&(304>>(4*8)));
I'm trying to convert this Java to JavaScript but JavaScript gives me 304 and 48 in all scenarios. I need it to match the Java and give values of 0 & 0.
Any ideas?
EDIT
Follow up, just to be clear, I need the JavaScript equivalent to equal 0, mimicking how the Java currently does it (the two examples above that equal 0 won't be changed in what we're developing).
So console.log(0xFF&(bits>>(4*8))) should equal 0, it currently equates to 48
javascript java hex long-integer calculation
javascript java hex long-integer calculation
edited Nov 14 '18 at 1:41
Dan James Palmer
asked Nov 14 '18 at 1:16
Dan James PalmerDan James Palmer
94952052
94952052
In Java,304
is anint
, so there is an implicit((4*8)%32)
for the number of bits to shift.bits
is along
, so there is an implicit((4*8)%64)
. JavaScript, I don't know...
– Ken Y-N
Nov 14 '18 at 1:28
1
And to followup on @KenY-N Javascript does all shifts as a 32bit number. So shifting by 32bits is ignored.
– lod
Nov 14 '18 at 1:31
add a comment |
In Java,304
is anint
, so there is an implicit((4*8)%32)
for the number of bits to shift.bits
is along
, so there is an implicit((4*8)%64)
. JavaScript, I don't know...
– Ken Y-N
Nov 14 '18 at 1:28
1
And to followup on @KenY-N Javascript does all shifts as a 32bit number. So shifting by 32bits is ignored.
– lod
Nov 14 '18 at 1:31
In Java,
304
is an int
, so there is an implicit ((4*8)%32)
for the number of bits to shift. bits
is a long
, so there is an implicit ((4*8)%64)
. JavaScript, I don't know...– Ken Y-N
Nov 14 '18 at 1:28
In Java,
304
is an int
, so there is an implicit ((4*8)%32)
for the number of bits to shift. bits
is a long
, so there is an implicit ((4*8)%64)
. JavaScript, I don't know...– Ken Y-N
Nov 14 '18 at 1:28
1
1
And to followup on @KenY-N Javascript does all shifts as a 32bit number. So shifting by 32bits is ignored.
– lod
Nov 14 '18 at 1:31
And to followup on @KenY-N Javascript does all shifts as a 32bit number. So shifting by 32bits is ignored.
– lod
Nov 14 '18 at 1:31
add a comment |
2 Answers
2
active
oldest
votes
The JLS, Section 15.19 covers shifting operators in Java.
If the promoted type of the left-hand operand is
int
, then only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x1f
(0b11111
). The shift distance actually used is therefore always in the range0
to31
, inclusive.
For an int
value such as 304
, the bit shift value of 4*8
, or 32, is really 0
, so no shifting takes place. Then a bit-and with 0xFF
yields 48
.
If the promoted type of the left-hand operand is
long
, then only the six lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x3f
(0b111111
). The shift distance actually used is therefore always in the range0
to63
, inclusive.
For a long
value, the bit shift value of 4*8
really does shift to the right 32 bits, which yields 0
.
This page covers JavaScript bit-shift operators.
Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers.
It appears that JavaScript converts the number to a 32-bit number, like a Java int
. It also appears that the same "only the least 5 bits" rule applies to the shift operand in JavaScript also.
console.log(304>>32); // Don't shift!
console.log(0xFF&(304>>32)); // Don't shift!
console.log(304>>33); // Shift by 1, not 33
console.log(0xFF&(304>>33)); // Shift by 1, not 33
Thanks for the answer, I'll check out the JavaScript bit-shift operators. I need the JavaScript to equal 0, like Java.
– Dan James Palmer
Nov 14 '18 at 1:39
add a comment |
If you want to get the same result with constants in Java as with variables, you need to pass 304 as a long constant with 304L
, like this:
System.out.println(304L>>(4*8));
System.out.println(0xFF&(304L>>(4*8)));
The reason is that you cannot shift an int
with 4*8=32 bits; Java will shift 32 modulo 32 = zero buts, since an int
is only 32 bits long.
Javascript, in constrast, doesn't support shifting 64-bit integers with the >>
operator; it treats every number that you pass to >>
as a 32-bit integer.
You could write your own function that does something similar:
function rshift(num, bits)
return Math.round(num / Math.pow(2,bits));
console.log(rshift(304, 4*8))
The rshift almost worked. One of the calculations is 0*8 for bits, which gives a value of 304. The Java equivalent gives 48
– Dan James Palmer
Nov 14 '18 at 2:09
You're saying that the Java codeSystem.out.println(304L >> (0*8))
gives you 48? Or thatSystem.out.println(0xff & (304L >> (0*8)))
? Gives you 48? Because the equivalent of the latter isconsole.log(0xff & rshift(304, 0*8))
and that outputs 48 in Javascript too.
– Erwin Bolwidt
Nov 14 '18 at 2:52
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291811%2fjava-hex-calculation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The JLS, Section 15.19 covers shifting operators in Java.
If the promoted type of the left-hand operand is
int
, then only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x1f
(0b11111
). The shift distance actually used is therefore always in the range0
to31
, inclusive.
For an int
value such as 304
, the bit shift value of 4*8
, or 32, is really 0
, so no shifting takes place. Then a bit-and with 0xFF
yields 48
.
If the promoted type of the left-hand operand is
long
, then only the six lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x3f
(0b111111
). The shift distance actually used is therefore always in the range0
to63
, inclusive.
For a long
value, the bit shift value of 4*8
really does shift to the right 32 bits, which yields 0
.
This page covers JavaScript bit-shift operators.
Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers.
It appears that JavaScript converts the number to a 32-bit number, like a Java int
. It also appears that the same "only the least 5 bits" rule applies to the shift operand in JavaScript also.
console.log(304>>32); // Don't shift!
console.log(0xFF&(304>>32)); // Don't shift!
console.log(304>>33); // Shift by 1, not 33
console.log(0xFF&(304>>33)); // Shift by 1, not 33
Thanks for the answer, I'll check out the JavaScript bit-shift operators. I need the JavaScript to equal 0, like Java.
– Dan James Palmer
Nov 14 '18 at 1:39
add a comment |
The JLS, Section 15.19 covers shifting operators in Java.
If the promoted type of the left-hand operand is
int
, then only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x1f
(0b11111
). The shift distance actually used is therefore always in the range0
to31
, inclusive.
For an int
value such as 304
, the bit shift value of 4*8
, or 32, is really 0
, so no shifting takes place. Then a bit-and with 0xFF
yields 48
.
If the promoted type of the left-hand operand is
long
, then only the six lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x3f
(0b111111
). The shift distance actually used is therefore always in the range0
to63
, inclusive.
For a long
value, the bit shift value of 4*8
really does shift to the right 32 bits, which yields 0
.
This page covers JavaScript bit-shift operators.
Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers.
It appears that JavaScript converts the number to a 32-bit number, like a Java int
. It also appears that the same "only the least 5 bits" rule applies to the shift operand in JavaScript also.
console.log(304>>32); // Don't shift!
console.log(0xFF&(304>>32)); // Don't shift!
console.log(304>>33); // Shift by 1, not 33
console.log(0xFF&(304>>33)); // Shift by 1, not 33
Thanks for the answer, I'll check out the JavaScript bit-shift operators. I need the JavaScript to equal 0, like Java.
– Dan James Palmer
Nov 14 '18 at 1:39
add a comment |
The JLS, Section 15.19 covers shifting operators in Java.
If the promoted type of the left-hand operand is
int
, then only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x1f
(0b11111
). The shift distance actually used is therefore always in the range0
to31
, inclusive.
For an int
value such as 304
, the bit shift value of 4*8
, or 32, is really 0
, so no shifting takes place. Then a bit-and with 0xFF
yields 48
.
If the promoted type of the left-hand operand is
long
, then only the six lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x3f
(0b111111
). The shift distance actually used is therefore always in the range0
to63
, inclusive.
For a long
value, the bit shift value of 4*8
really does shift to the right 32 bits, which yields 0
.
This page covers JavaScript bit-shift operators.
Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers.
It appears that JavaScript converts the number to a 32-bit number, like a Java int
. It also appears that the same "only the least 5 bits" rule applies to the shift operand in JavaScript also.
console.log(304>>32); // Don't shift!
console.log(0xFF&(304>>32)); // Don't shift!
console.log(304>>33); // Shift by 1, not 33
console.log(0xFF&(304>>33)); // Shift by 1, not 33
The JLS, Section 15.19 covers shifting operators in Java.
If the promoted type of the left-hand operand is
int
, then only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x1f
(0b11111
). The shift distance actually used is therefore always in the range0
to31
, inclusive.
For an int
value such as 304
, the bit shift value of 4*8
, or 32, is really 0
, so no shifting takes place. Then a bit-and with 0xFF
yields 48
.
If the promoted type of the left-hand operand is
long
, then only the six lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value0x3f
(0b111111
). The shift distance actually used is therefore always in the range0
to63
, inclusive.
For a long
value, the bit shift value of 4*8
really does shift to the right 32 bits, which yields 0
.
This page covers JavaScript bit-shift operators.
Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers.
It appears that JavaScript converts the number to a 32-bit number, like a Java int
. It also appears that the same "only the least 5 bits" rule applies to the shift operand in JavaScript also.
console.log(304>>32); // Don't shift!
console.log(0xFF&(304>>32)); // Don't shift!
console.log(304>>33); // Shift by 1, not 33
console.log(0xFF&(304>>33)); // Shift by 1, not 33
console.log(304>>32); // Don't shift!
console.log(0xFF&(304>>32)); // Don't shift!
console.log(304>>33); // Shift by 1, not 33
console.log(0xFF&(304>>33)); // Shift by 1, not 33
console.log(304>>32); // Don't shift!
console.log(0xFF&(304>>32)); // Don't shift!
console.log(304>>33); // Shift by 1, not 33
console.log(0xFF&(304>>33)); // Shift by 1, not 33
answered Nov 14 '18 at 1:30
rgettmanrgettman
149k21205289
149k21205289
Thanks for the answer, I'll check out the JavaScript bit-shift operators. I need the JavaScript to equal 0, like Java.
– Dan James Palmer
Nov 14 '18 at 1:39
add a comment |
Thanks for the answer, I'll check out the JavaScript bit-shift operators. I need the JavaScript to equal 0, like Java.
– Dan James Palmer
Nov 14 '18 at 1:39
Thanks for the answer, I'll check out the JavaScript bit-shift operators. I need the JavaScript to equal 0, like Java.
– Dan James Palmer
Nov 14 '18 at 1:39
Thanks for the answer, I'll check out the JavaScript bit-shift operators. I need the JavaScript to equal 0, like Java.
– Dan James Palmer
Nov 14 '18 at 1:39
add a comment |
If you want to get the same result with constants in Java as with variables, you need to pass 304 as a long constant with 304L
, like this:
System.out.println(304L>>(4*8));
System.out.println(0xFF&(304L>>(4*8)));
The reason is that you cannot shift an int
with 4*8=32 bits; Java will shift 32 modulo 32 = zero buts, since an int
is only 32 bits long.
Javascript, in constrast, doesn't support shifting 64-bit integers with the >>
operator; it treats every number that you pass to >>
as a 32-bit integer.
You could write your own function that does something similar:
function rshift(num, bits)
return Math.round(num / Math.pow(2,bits));
console.log(rshift(304, 4*8))
The rshift almost worked. One of the calculations is 0*8 for bits, which gives a value of 304. The Java equivalent gives 48
– Dan James Palmer
Nov 14 '18 at 2:09
You're saying that the Java codeSystem.out.println(304L >> (0*8))
gives you 48? Or thatSystem.out.println(0xff & (304L >> (0*8)))
? Gives you 48? Because the equivalent of the latter isconsole.log(0xff & rshift(304, 0*8))
and that outputs 48 in Javascript too.
– Erwin Bolwidt
Nov 14 '18 at 2:52
add a comment |
If you want to get the same result with constants in Java as with variables, you need to pass 304 as a long constant with 304L
, like this:
System.out.println(304L>>(4*8));
System.out.println(0xFF&(304L>>(4*8)));
The reason is that you cannot shift an int
with 4*8=32 bits; Java will shift 32 modulo 32 = zero buts, since an int
is only 32 bits long.
Javascript, in constrast, doesn't support shifting 64-bit integers with the >>
operator; it treats every number that you pass to >>
as a 32-bit integer.
You could write your own function that does something similar:
function rshift(num, bits)
return Math.round(num / Math.pow(2,bits));
console.log(rshift(304, 4*8))
The rshift almost worked. One of the calculations is 0*8 for bits, which gives a value of 304. The Java equivalent gives 48
– Dan James Palmer
Nov 14 '18 at 2:09
You're saying that the Java codeSystem.out.println(304L >> (0*8))
gives you 48? Or thatSystem.out.println(0xff & (304L >> (0*8)))
? Gives you 48? Because the equivalent of the latter isconsole.log(0xff & rshift(304, 0*8))
and that outputs 48 in Javascript too.
– Erwin Bolwidt
Nov 14 '18 at 2:52
add a comment |
If you want to get the same result with constants in Java as with variables, you need to pass 304 as a long constant with 304L
, like this:
System.out.println(304L>>(4*8));
System.out.println(0xFF&(304L>>(4*8)));
The reason is that you cannot shift an int
with 4*8=32 bits; Java will shift 32 modulo 32 = zero buts, since an int
is only 32 bits long.
Javascript, in constrast, doesn't support shifting 64-bit integers with the >>
operator; it treats every number that you pass to >>
as a 32-bit integer.
You could write your own function that does something similar:
function rshift(num, bits)
return Math.round(num / Math.pow(2,bits));
console.log(rshift(304, 4*8))
If you want to get the same result with constants in Java as with variables, you need to pass 304 as a long constant with 304L
, like this:
System.out.println(304L>>(4*8));
System.out.println(0xFF&(304L>>(4*8)));
The reason is that you cannot shift an int
with 4*8=32 bits; Java will shift 32 modulo 32 = zero buts, since an int
is only 32 bits long.
Javascript, in constrast, doesn't support shifting 64-bit integers with the >>
operator; it treats every number that you pass to >>
as a 32-bit integer.
You could write your own function that does something similar:
function rshift(num, bits)
return Math.round(num / Math.pow(2,bits));
console.log(rshift(304, 4*8))
answered Nov 14 '18 at 1:32
Erwin BolwidtErwin Bolwidt
23.9k123858
23.9k123858
The rshift almost worked. One of the calculations is 0*8 for bits, which gives a value of 304. The Java equivalent gives 48
– Dan James Palmer
Nov 14 '18 at 2:09
You're saying that the Java codeSystem.out.println(304L >> (0*8))
gives you 48? Or thatSystem.out.println(0xff & (304L >> (0*8)))
? Gives you 48? Because the equivalent of the latter isconsole.log(0xff & rshift(304, 0*8))
and that outputs 48 in Javascript too.
– Erwin Bolwidt
Nov 14 '18 at 2:52
add a comment |
The rshift almost worked. One of the calculations is 0*8 for bits, which gives a value of 304. The Java equivalent gives 48
– Dan James Palmer
Nov 14 '18 at 2:09
You're saying that the Java codeSystem.out.println(304L >> (0*8))
gives you 48? Or thatSystem.out.println(0xff & (304L >> (0*8)))
? Gives you 48? Because the equivalent of the latter isconsole.log(0xff & rshift(304, 0*8))
and that outputs 48 in Javascript too.
– Erwin Bolwidt
Nov 14 '18 at 2:52
The rshift almost worked. One of the calculations is 0*8 for bits, which gives a value of 304. The Java equivalent gives 48
– Dan James Palmer
Nov 14 '18 at 2:09
The rshift almost worked. One of the calculations is 0*8 for bits, which gives a value of 304. The Java equivalent gives 48
– Dan James Palmer
Nov 14 '18 at 2:09
You're saying that the Java code
System.out.println(304L >> (0*8))
gives you 48? Or that System.out.println(0xff & (304L >> (0*8)))
? Gives you 48? Because the equivalent of the latter is console.log(0xff & rshift(304, 0*8))
and that outputs 48 in Javascript too.– Erwin Bolwidt
Nov 14 '18 at 2:52
You're saying that the Java code
System.out.println(304L >> (0*8))
gives you 48? Or that System.out.println(0xff & (304L >> (0*8)))
? Gives you 48? Because the equivalent of the latter is console.log(0xff & rshift(304, 0*8))
and that outputs 48 in Javascript too.– Erwin Bolwidt
Nov 14 '18 at 2:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291811%2fjava-hex-calculation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
In Java,
304
is anint
, so there is an implicit((4*8)%32)
for the number of bits to shift.bits
is along
, so there is an implicit((4*8)%64)
. JavaScript, I don't know...– Ken Y-N
Nov 14 '18 at 1:28
1
And to followup on @KenY-N Javascript does all shifts as a 32bit number. So shifting by 32bits is ignored.
– lod
Nov 14 '18 at 1:31