Thread: A 6 Byte Number Data Type

  1. #1
    Registered User
    Join Date
    Jul 2002

    A 6 Byte Number Data Type

    Does C++ have a 6 byte Number Data Type??.
    I could not find one so I wrote my own class object for it
    floats are 4
    doubles are 8

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    no, it doesnt. All it's got are chars, ints, floats, and longs.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well depending on your compiler (which you don't mention), you could have
    long long int foo;
    __int64_t bar;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    I just posted on another thread about bitfields, which you might be able to use. You can build a struct that aligns a specific number of bits for a data type.

    struct Int36
         int num : 36;
    it might get a little cumbersome to use, but I'm sure it wouldn't be too much of a hassle.

  5. #5
    There are many ways you can accomplish it. You could do like skorman said with a little bit of inconvenience (and I mean little). I've used bitfields for embedded programming a lot. Worked like a charm for our robot controller.

    You could go with Salem's method, if you don't care about wasting a little bit of space, which I again, I emphasise little

    You could even make a C++ class and overload all the operators if you want to go all out

  6. #6
    Registered User
    Join Date
    Aug 2003
    You can get this bahavior by using std::bitset
    Last edited by okinrus; 07-08-2004 at 05:34 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  2. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  3. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM