Hi all,

I am learning how to operate with the TTN and i am going to need some help. i am trying to understand how this code works but there are things that i don’t get why. if someone can help me, it will help me a lot.

function Decoder(bytes, port) {

function bytesToFloat(bytes) {

//LSB Format (least significant byte first).

var bits = bytes[3]<<24 | bytes[2]<<16 | bytes[1]<<8 | bytes[0]; // takes the four bits bit[0] , bit[1]

var sign = (bits>>>31 === 0) ? 1.0 : -1.0; // We take the bit[31] and see if it’s not equal to 0 we assign 1.

var e = bits>>>23 & 0xff;// WHY ARE THEY DOING THIS?

var m = (e === 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000;// WHAT ARE THEY TRYING TO DO?.

var f = sign * m * Math.pow(2, e - 150);// AND IN HERE?

return f;

}return {

temp: bytesToFloat(bytes.slice(0, 4))

};

}

Thanks for your help.

Regards,