-1

I have an Integer 138 that i want to covert into an 8 bit signed Integer that will become -118. I have tried unpack, intval and several othe php function but they didn't worked. How should i do this, stuck in this for few days now.

1 Answer 1

3

There may be other ways, but a quick look at using pack and unpack - pack with C stores it as an unsigned and the unpack with c gets the signed value back...

echo unpack( 'c', pack('C', 138))[1];

gives

-118
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.