Home AMX User Forum AMX Technical Discussion

Char to Integer question

I have this two byte character array { $08, $20 }

I want to compare it with decimal 2080
( 0x820 == 2080 )

Is there a simple way ?

Comments

  • HedbergHedberg Posts: 671
    nSum = type_cast($08 << 8) + $20

    or

    c1 = $08
    c2 = $20

    nSum = type_cast(c1 << 8 + c2)

    the << operator is the binary lshift operator. << 8 is the same as *256
Sign In or Register to comment.