Declaring a binary literal


#1

How does one write const x = 00010000; or static x = 00010000; in Squirrel. Other languages you can place 0b or B in front of the binary number.


#2

Squirrel doesn’t support binary literals. You’d have to use hex, eg const x = 0x10.

If you’re wanting to embed binary blobs in your code, you do this as const strings, eg:

const image = “\x01\x00\xff\xe5”;

…these then live in the read only program space of the imp.


#3

thanks


#4

I’ll make a note of that in the Squirrel Programming Guide.