I am having below code to convert DEC to BIN and then reverse it and then convert back to DEC.
I am getting correct results when I pass ODD numbers but for EVEN numbers it is not accurate.
Could someone help me what I am doing wrong?
function mirror_bits(n) {
var NumFromInvNum = parseInt(n.toString(2).split("").reverse().join(""), 2);
return NumFromSaleNum;
}
Example values I am seeing issue are
30038174 — not working
30038173 — working
30038180 — not working
30038035 — working