编辑代码

let res = test('ff f0 00')
console.log("out:" + res )

function test(x){
    var ss = x.split(' ');
    var st = (parseInt(ss[0], 16 ) << 12 | parseInt(ss[1], 16 ) << 4 | parseInt(ss[2], 16 ) >> 4);
    console.log(st);
    if ( st & 524288) {
        st |= 4293918720;
        console.log(st);
    }
    var s = (st * 40)/524.288;
    
    return s.toFixed(0);
}