Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: RobinLinus on February 06, 2020, 10:58:56 AM



Title: Implementing OP_MUL with OP_ADD
Post by: RobinLinus on February 06, 2020, 10:58:56 AM
For fun I implemented OP_MUL using OP_ADD. You can find the code here on Github. (https://github.com/coins/bitcoin-scripts/blob/master/op_mul.md)

Feedback very appreciated!

And I have a question: do you guys know any good source for advanced bitcoin scripts? Is there something like a library for scripts?


Title: Re: Implementing OP_MUL with OP_ADD
Post by: pooya87 on February 06, 2020, 02:19:35 PM
Quote
The result of a * b must fit into a signed 32-bit integer.
generally speaking result of all arithmetic operations can overflow that is why the result is always a 64-bit integer. the only rule is that the value that is popped to be evaluated as an integer can not be bigger than 32-bit.

you should also add some explanation about your OP_MUL, it is not easy to figure out.