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

Arithmetic Calculate (64 bits)

How can I multiply 2 data that result in a 64 bit value?

For example:

unsigned long a = 4000000000, c;
unsigned int b = 60000;

c = a * b; //this have a problem!!!

Has any library that can I use?

Thanks

Leonardo

Parents
  • if you need to do 64-bit arithmetic, then you are probably using the wrong processor!

    Just by way of counter-example:

    The IEEE 802 standard (Ethernet, and others) specifies that the various counters it specifies may not roll over any faster than 57 minutes. It also specifies that any counter that can't be done in 32 bits has to be 64 bits wide. Approximately 2/3 of the counters at a gigabit rate, as for Gigabit Ethernet, thus have to be 64 bit counters.

    An embedded 8051 works really well to control an Ethernet chip. It doesn't have a lot to do in terms of raw horsepower. And it's not doing intensive math on those 64 bit integers. It's just adding a hardware register to a U64 once in a while -- minutes, maybe. Or, as another example, consider the IEEE MAC address, 48 bits wide. Perhaps you need to generate a series of a few MAC addresses, starting from a base address. So you increment a U64 a few times. Wide results do not necessarily correspond to a need for lots of MIPS or RAM. Nuclear weapon simulation and indexing memory-mapped Google database files aren't the only uses for 64 bit math.

    It would be quite nice if Keil provided 64-bit integer libraries.

Reply
  • if you need to do 64-bit arithmetic, then you are probably using the wrong processor!

    Just by way of counter-example:

    The IEEE 802 standard (Ethernet, and others) specifies that the various counters it specifies may not roll over any faster than 57 minutes. It also specifies that any counter that can't be done in 32 bits has to be 64 bits wide. Approximately 2/3 of the counters at a gigabit rate, as for Gigabit Ethernet, thus have to be 64 bit counters.

    An embedded 8051 works really well to control an Ethernet chip. It doesn't have a lot to do in terms of raw horsepower. And it's not doing intensive math on those 64 bit integers. It's just adding a hardware register to a U64 once in a while -- minutes, maybe. Or, as another example, consider the IEEE MAC address, 48 bits wide. Perhaps you need to generate a series of a few MAC addresses, starting from a base address. So you increment a U64 a few times. Wide results do not necessarily correspond to a need for lots of MIPS or RAM. Nuclear weapon simulation and indexing memory-mapped Google database files aren't the only uses for 64 bit math.

    It would be quite nice if Keil provided 64-bit integer libraries.

Children