Category: off topic

32 bit integer to 4 bytes

Squirrel on Electric Imp #require “JSONEncoder.class.nut:2.0.0” local number = 1523187384; local record = array(4); local result = 0; local byteArray = array(4); local record2 = array(4); local result2 = 0; local byteArray2 = array(4); // method 1 and before shift right record[0] = ((number & 0xff000000) >> 24); record[1] = ((number & 0x00ff0000) >> 16); […]