将Double64转换为Long64并重新使用JavaScript

我需要将Double64转换为Long64并重新使用JavaScript,例如Java上的Double.doubleToLongBits()和Double.longBitsToDouble()。并且方法的结果必须与Java中的结果相同。例如1435.036452-> 4654026172507377535-> 1435.036452,或-1435.036452-> -4569345864347398273-> -1435.036452。我不理解,我的代码可以很好地将Double64转换为Long64,但是我无法取回我的价值。 Double64到Long64:

function toString64bitFloat(number) {
if(number === undefined || isNaN(number))
    return 0;
let result = "";
const dv = new DataView(new ArrayBuffer(8));
dv.setFloat64(0, number, false);
for (let i = 0; i < 8; i++) {
    let bits = dv.getUint8(i).toString(2);
    if (bits.length < 8)
        bits = new Array(8 - bits.length).fill('0').join("") + bits;
    result += bits;
}
return result;

}

function stringToLong64(bitString) {
if(bitString === undefined || isNaN(bitString))
    return 0;
let result = new BigInt64Array(1);
result[0] = BigInt(0);
if(bitString[0] === "1"){
    for(let i = bitString.length; i > 0; i--)
        if(bitString[i] === "0")
            result[0] += BigInt(Math.pow(2, 63 - i));
    result[0] = -result[0] - BigInt(1);
}else{
    for(let i = bitString.length; i > 0; i--)
        if(bitString[i] === "1")
            result[0] += BigInt(Math.pow(2, 63 - i));
}
return result[0];

}

Long64到Double64:

function toString64bitInt(number) {
let result = "";
let temp = number;
if(temp > 0){
    result += "0";
    for(let i = 1; i < 64; i++){
        if(temp - BigInt(Math.pow(2, 63 - i)) >= 0){
            result += "1";
            temp -= BigInt(Math.pow(2, 63 - i));
        } else {
            result += "0"
        }
    }
} else {
    result += "1";
    temp = -temp + BigInt(0);
    for(let i = 0; i < 63; i++){
        if(temp - BigInt(Math.pow(2, 63 - i)) >= 0){
            result += "0";
            temp -= BigInt(Math.pow(2, 63 - i));
        } else {
            result += "1"
        }
    }
}

return result;

}

function stringTofloat64(bitString) {
let result = new Float64Array(1);
result[0] = 0.0;

if(bitString[0] === '1'){
    for(let i = 1; i > 12; i++)
        if(bitString[i] === '0')
            result[0] += Math.pow(2, 11 - i);
    for(let i = 12; i > 64; i++)
        if(bitString[i] === '0')
            result[0] += Math.pow(2, -(52 - i + 12));
    result[0] = -result[0];
}else{
    for(let i = 1; i > 12; i++){
        if(bitString[i] === '1'){
            result[0] += Math.pow(2, 11 - i);
        }
    }
    for(let i = 12; i > 64; i++)
        if(bitString[i] === '1'){
            result[0] += Math.pow(2, -(52 - i + 12));
        }
}
return result[0];

}