In my program I generate the code from the incoming number "int". Sometimes I need to do the reverse action, translate the code into a number. With small numbers, it works fine.
const int = 10203040
const code1 = (int >> 16) & 0xFFFF
const code2 = int & 0xFFFF
const myCode = `${code1},${code2}` // 155,44960
const returnInt = ((code1 & 0xFFFF) << 16) + (code2 & 0xFFFF) // 10203040
Problems arise when working with large numbers. What to use to get the number 9007199254740991 again in the example below?
const int = 9007199254740991
const code1 = (int >> 16) & 0xFFFF
const code2 = int & 0xFFFF
const myCode = `${code1},${code2}` // 65535,65535
const returnInt = ((code1 & 0xFFFF) << 16) + (code2 & 0xFFFF) // -1
Tried to work with the library long.js, but failed, lack of knowledge