Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • May be relevant Commented Feb 23, 2020 at 0:08
  • How about bit shifting with 64 bit integers? Commented Feb 23, 2020 at 0:09
  • Since the sum of the two numbers is larger than the storage, there is nowhere to store the number, which is why there is an overflow. If you could just check somewhere for the overflow there would be no need for it to be an overflow at all. But, you can detect the overflow and do something else, if(UINT_MAX - a < b) then handle_it() Commented Feb 23, 2020 at 0:18
  • 2
    unsigned long long int is a standard C type that must have at least 64 bits, so, for your 32-bit example, the product can be computed as (unsigned long long int) a * b, after which the low and high 32 bits can be extracted by shifting and masking. Commented Feb 23, 2020 at 0:18
  • @Dr.-Ing.GerhardStein problem will come bach with unsigned long long. What type then? Commented Feb 23, 2020 at 0:54