function getOther(nums) { let str=nums.toString(2) let arr = str.split('') let newArr = [] arr.forEach((item, index) => { if (item == '0') { newArr.push(1) }else{ newArr.push(0) } }) nums_bin= newArr.join('') nums_ten=parseInt(nums_bin,2)+1 res=nums_ten*0.1-2*nums_ten*0.1 return res.toFixed(1) } console.log(getOther(65136))