Thread: Is there a 24-bit var in C++?

  1. #1
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109

    Question Is there a 24-bit var in C++?

    Is there a 24-bit var in C++?
    int a; don't make a program without it.

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    thanks it's 3 bytes but i can't figerout how to use it.
    I tried to use it like this foo=0; and i get the error
    error C2440: '=' : cannot convert from 'const int' to 'unsigned char [3]'
    There are no conversions to array types, although there are conversions to references or pointers to arrays
    how can i fix this?

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    you just do:

    foo poo;

    poo.myvar

    it will have all the proper operations defined for it.

    EDIT: That would, of course, be for the bitfield, not the array. There is no direct way to use the array version.
    Last edited by Polymorphic OOP; 04-06-2003 at 03:18 AM.

  4. #4
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    That was weird it used my friends name. He logged in once on my pc and about a month or so but it shouldn't do that
    int a; don't make a program without it.

  5. #5
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    thanks
    int a; don't make a program without it.

  6. #6
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    no wait it get the error:
    error C2228: left of '.myvar' must have class/struct/union type
    from doing
    foo.myvar=0;
    int a; don't make a program without it.

  7. #7
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    it acts like a 24bit but it takes 4bytes can this be fixed?
    I do sizeof(poo); and it gets 4 if i do
    sizeof(poo.myvar) i get the error
    error C2070: illegal sizeof operand
    int a; don't make a program without it.

  8. #8
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    ya i got VC++ that sucks
    int a; don't make a program without it.

  9. #9
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    I just wanted to see if it was possable and wanted to save some space in ram if i only need to go 16 million. I also wanted to save some space in files but i could just make a fuction to do that my self.
    int a; don't make a program without it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. porting application from 32 bit to 64 bit error
    By gandalf_bar in forum Linux Programming
    Replies: 1
    Last Post: 09-14-2005, 09:20 AM
  2. Bit processing in C
    By eliomancini in forum C Programming
    Replies: 8
    Last Post: 06-07-2005, 10:54 AM
  3. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 08:02 PM
  4. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM