Hi i want to declare a datatype of size 3 bytes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anilchilli
    New Member
    • Nov 2009
    • 1

    Hi i want to declare a datatype of size 3 bytes

    I dont want to use the standard datatype
    can any body help me how to declare my own datatypes of my
    own choice.
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    You can have a structure and declare the char array of size 3.
    Or best way to create a class, here you can also define custom methods to perform operations on your char array

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      However you would be far better off just using a 4 byte integer and range checking it before it is used. It is unlikely you will save enough memory by having a 3 byte rather than a 4 byte int to make ashitpro suggestions worth while.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        What is this 3 byte datatype supposed to look like?

        You use struct or class to declare your own datatypes.

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Actually in fairness I have worked with compilers that had 3 byte ints you declared them

          long short
          or
          short long

          However as a note to the OP that was most definitely a compiler extension and caused not end of grief when I determined that the clients existing code base was written to a poor standard and attempted to use a static analysis tool on it.

          Comment

          Working...