23
tahnik
8y

Just found this in our code:

UINT8 variableName = 500;

Any developer who is getting paid should know the largest value an unsigned 8 bit integer can hold

Comments
  • 7
    Actually the value is 255. it can hold 256 values (0 included)
  • 2
    @BartBB Yeah I meant 2^8 is 256. They should know it
  • 2
    I assumed so. Wasn't doubting your knowledge. Just pointed it out @tahnik
  • 0
    Surely your compiler gives a warning?
  • 5
    typedef UINT8 uint16_t;
  • 1
    @Gauthier The compiler does gives a warning. No idea why whoever wrote this ignored it. Maybe in the beginning it was less then 256 then a douche changed it later.

    This code is being changed from 2005
  • 3
    @Gauthier

    typedef UINT8 uint16_t;

    Man you're evil
  • 1
    oh man.. the typedef "hack" brings back memories to an old rant, I posted a while ago...
  • 0
    Yeah I wouldn't do the typedef hack unless I was fixing to leave in a few months and everybody pissed me off
  • 0
    is tbere even a uint8 (in c# i think you would use "byte" instead)
  • 1
  • 0
    @JaggerJo uint8_t is in standard C, it's in stdint.h. Some people dislike the _t (it's really only a matter of getting used to it) so they redefine it.
Add Comment