1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Create "long long" type in C++

Discussion in 'Embedded' started by Al Williams, Sep 16, 2004.

  1. Al Williams

    Al Williams Guest

    We have a database library we want to use in our embedded application but it
    requires 64 bit longs (long long or _int64). Our current compiler doesn't
    support this type and won't anytime soon. As it is a C++ compiler, is it
    not true that I can overload the basic arithmetic operators and create my
    own "longlong" type?

    I'm not terribly familiar with C++ but I figure it something that can be
    done and maybe it's been done already.

    Anyone know of any public domain code for this?
    Al Williams, Sep 16, 2004
    1. Advertisements

  2. Al Williams

    Robert Scott Guest

    Yes, it can be done. But it won't as efficient as it could be if it
    were implemented as a native type by the compiler. C/C++ is very poor
    at handling a carry or borrow with the same efficiency as assembler.
    But if your compiler supports in-line assembler, then you might be
    able to do it. On the other hand, if performance is not an issue,
    then forget about assembler and efficiency and make a C++ class to do
    _int64 arithmetic however you want.

    -Robert Scott
    Ypsilanti, Michigan
    (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)
    Robert Scott, Sep 16, 2004
    1. Advertisements

  3. Al Williams

    Chris Hills Guest

    YEs.... but you are talking about writing a maths library.
    So I see. Ask inthe comp.lang.c++ NG
    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\
    /\/\/ www.phaedsys.org \/\/
    Chris Hills, Oct 7, 2004
  4. We have a database library we want to use in our embedded application but
    You can do that, but be careful with what you want to do. If it were
    me, I'd resist doing a full C++ library with overloads and stuff. I'd much
    to isolate exactly which parts of the program needed to be done in 64 bits
    define functions solely for those parts which needed it.

    I had to do this sort of thing where the original program (in assembler!)
    needed to generate Standard Deviations (which involves squaring and rooting)
    of values that started off as 32 bits. This was the only part of the program
    that needed 64 bits, so what I did was to create a "standard deviation
    accumulator" class in C++: it took
    its input (and produced its output) in the 32 bit domain, but worked
    internally in
    64 bits.

    Richard [in PE12]
    Endymion Ponsonby-Withermoor III, Oct 8, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.