# How do I convert byte to int?

0 favourites
• 7 posts
• So, I've got a 8-byte string (32-bit integer value) which I need to convert into bit values and/or to an integer.

More spesifically, I want to convert a 8 byte data I read from a file's header into it's numerical value.

How can I do such conversions in C2?

• Do you mean converting a binary number to a decimal number?

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Do you mean the sort. Of thing you would use a strict for in c ? Unless JavaScript's runtime does this, you probably can't, it uses 64 bit floats

• LittleStain Yeah, I mean kind of that.

I have this ASCII data of "ü6‡ " (Little Endian) which is FC 36 87 00 in HEX (which I can't access in Construct2), and I want to convert it into it's Decimal equalivent of 8861436.

Any way to do this in construct?

• I'm not sure there is such a function/feature right away in C2, you might need to code your own.

To be fair, this might even require you to make some third-part plugin using C2 SDK.

Apparently JavaScript does have ways to do this conversion so making a plugin for it should work in the end.

If you manage in getting directly the maths behind this conversion you can even try and implement your own Function in C2 possibly using system actions and expressions in the process (I'm not sure about the feasibility to be honest though).

• There are a few expressions already:

getbit(x, n)

Get the nth bit of x represented as a 32-bit integer. For example getbit(7, 0) will get the least significant bit of the number 7 when represented as a 32-bit integer. Returns either 0 or 1.

setbit(x, n, b)

Set the nth bit of x represented as a 32-bit integer to b (either 0 or 1). The resulting 32-bit integer is returned.

togglebit(x, n)

Toggle the nth bit of x represented as a 32-bit integer. If that bit is 0, it is set to 1; if it is 1, it is set to 0. The resulting 32-bit integer is returned.