A 6 Byte Number Data Type

This is a discussion on A 6 Byte Number Data Type within the C++ Programming forums, part of the General Programming Boards category; Does C++ have a 6 byte Number Data Type??. I could not find one so I wrote my own class ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    47

    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
    l

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

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    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.

    Code:
    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
    Banned
    Join Date
    Dec 2003
    Posts
    367
    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
    Posts
    470
    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, 02:49 PM
  2. Replies: 16
    Last Post: 10-29-2006, 04: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21