Using Divw in Pyteal v6

Dear Algorand developers,

Great job on the new AVM release on Betanet! I am playing around with some of the new opcodes and trying to get a better understanding of them.

Specifically, I am trying to understand Divw opcode in Pyteal v6.


def divide_func():
    numerator = Int(453)
    denominator = Int(7894030)
    This next line is what confuses me. 
    #result = Divw(high, low, divisor) 

    return Seq([ 
        Return( result ),

Question 1: What makes Divw different from the normal / opcode?

Question 2: How do I extract the high and low bits from the numerator?

Question 3: Does this opcode return more than one value on the stack? If so, how would I use them in the above context?

divw requires the result to fit an uint64.

Since it is not yet available in TestNet/MainNet, but only in BetaNet, the documentation is only in the specs:

Regarding high/low for numerator, it’s to allow the numerator to have more than 64-bits.
For example, the number 10*2^64+42 = 184467440737095516202 would be defined as:

high = Int(10)
low = Int(42)

But honestly, if you need numbers with more than 64 bits, it is often much simpler to use the byteslice arithmetic:

1 Like