This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

64 bit Maths

I am trying to calculate some quadrature polynomials and I'm not getting enough resolution with the 32 bit fp maths library.
Does anyone know of a 64 bit package either using integers or fp - I don't mind which as I can use either.
I need nothing more complicated than the usual 4 functions; add, subtract, multiply and divide.
Any help would be greatly appreciated.

Parents
  • Shorn of the C++ syntax, the point of the Graham's link is that you can implement 64-bit math in C using 32-bit pieces native to the compiler. You don't really need assembler, unless you need the absolute best performance. The main insight is that you can detect rollover by comparing the operands before and after the operation, instead of with the carry bit. Other than that, you just do the math the way you were taught to do it by hand in grade school. Details in Graham's links.

    Only Keil can give us 64-bit math that works with the actual math operators. Otherwise, we're stuck with a relatively clumsy pointer-passing procedural API.

    U64AddEqU32 (U64* dst, U32* src);
    U64SubEqU32 (U64* dst, U32* src);
    U64MulEqU32 (U64* dst, U32* src);

    etc etc etc.

    (Those pointers might well be best declared as always xdata; you can't pass two generic pointers to one function without spilling out of registers. And there's probably not a lot of 64-bit integers living in data space anyway.)

Reply
  • Shorn of the C++ syntax, the point of the Graham's link is that you can implement 64-bit math in C using 32-bit pieces native to the compiler. You don't really need assembler, unless you need the absolute best performance. The main insight is that you can detect rollover by comparing the operands before and after the operation, instead of with the carry bit. Other than that, you just do the math the way you were taught to do it by hand in grade school. Details in Graham's links.

    Only Keil can give us 64-bit math that works with the actual math operators. Otherwise, we're stuck with a relatively clumsy pointer-passing procedural API.

    U64AddEqU32 (U64* dst, U32* src);
    U64SubEqU32 (U64* dst, U32* src);
    U64MulEqU32 (U64* dst, U32* src);

    etc etc etc.

    (Those pointers might well be best declared as always xdata; you can't pass two generic pointers to one function without spilling out of registers. And there's probably not a lot of 64-bit integers living in data space anyway.)

Children