Home AMX User Forum NetLinx Studio

Hexadecimal addition

hi guys,
Which datatype can I use for hexadecimal numbers?

Comments

  • ericmedleyericmedley Posts: 4,177
    hi guys,
    Which datatype can I use for hexadecimal numbers?

    Integer, there's no fundamental difference between math operators on decimal or hexadecimal.
  • a_riot42a_riot42 Posts: 1,624
    hi guys,
    Which datatype can I use for hexadecimal numbers?

    I use chars, because they are smaller.
    Paul
  • PhreaKPhreaK Posts: 966
    If you are only playing with values <= 0xFF then char's will work fine (they're the same as byte's in other languages), otherwise use a data type that will be large enough to handle your highest expected value.
  • DHawthorneDHawthorne Posts: 4,584
    The thing to keep in mind here is that "hexadecimal" is not a data type. It's a notation type. Processors don't care about notation, that's for our benefit. 1101b, $OD, and 13 all have exactly the same value, they are just different ways to write it down for all of us not conversant in machine language. All the rules for any kind of data apply, including the size of the variable used to store it, and the operators to manipulate it. Just as long as you are consistent with your notation, it will come out all right. Adding ASCII to the equation does muddy the waters a bit, but I'll leave off that discussion for now :) ... but, to simplify, ASCII is yet another form of notation that has a specific use, and again, as long as you are consistent, you will be fine.
Sign In or Register to comment.