# 64 bit arithmetic soft fork

**URL:** <https://delvingbitcoin.org/t/64-bit-arithmetic-soft-fork/397>\
**Category:** Protocol Design\
**Tags:** softfork\
**Created:** [January 10, 2024, 3:36pm UTC](https://delvingbitcoin.org/t/64-bit-arithmetic-soft-fork/397 "2024-01-10T15:36:12Z")\
**Posts on this page:** 1\
**Showing post:** 36

<div class="post-metadata">

**Author:** ![EthanHeilman](https://delvingbitcoin.org/user_avatar/delvingbitcoin.org/ethanheilman/32/328_2.png) [@EthanHeilman](https://delvingbitcoin.org/u/EthanHeilman)\
**Post date:** [February 1, 2024, 10:21pm UTC](https://delvingbitcoin.org/t/64-bit-arithmetic-soft-fork/397/36 "2024-02-01T22:21:46Z")

</div>

@Chris_Stewart_5

Continuing my question from BIP.

The BIP states: “If the operation results in an overflow, push false onto the stack”.

I would propose altering this to so that the result and the overflow amount are pushed onto the stack.

**Case 1, no overflow:**

1, 1, OP\_ADD64 → 2, 0

where 2 is the result and 0 is the overflow amount.

**Case 2, overflow:**

2^64 - 1, 5, OP\_ADD64 → 4, 1

where 4 is the result (mod 2^64), and 1 is the overflow amount. You can think of these two stack values as representing the 128 bit number 2^64+4 broken into two 64 bit chunks.

Push values on the stack in this fashion makes it esimple use these 64 opcodes to do math on numbers larger than 64 bits by chunking them into 64-bit stack elements. The overflow amount tells you how much to carry into the next chunk.

You’d still get the benefit of having a flag to check, if overflow amount is not 0, overflow occurred.

I think the BIP as written lets you add numbers larger than 64-bits using a similar chunking approach, but it is less straight forward and requires IF statements and substructions operations.

---

_[View the full topic](https://delvingbitcoin.org/t/64-bit-arithmetic-soft-fork/397)._
