This forum is a read-only archive. Posting, replying and signing in are disabled.

Complex math calculation

hungpq

AVM currently now support almost like other blockchain platform so there are more and more defi app to follow in the upcoming days.

So i want to ask how to perfrom complex pow math (with large number). i can see bytesadd, … but cant seem to find with pow calculation. if can, can you give me example of how to use them in PyTeal (what happend if overflow, etc…)

Thanks for reading.

Ben

Hi Hung,

I think the exp opcode might be what you’re looking for in the case of pow

Overflow would result in termination of the program and failure of the transaction.

Ben

hungpq

thanks for your answer
what is the different between exp and expw? it would be great if you can give some example.

and also i want to know how to do bit shift in teal? for example i want to express the value 4 and 7 in a single bytes, each value can have 64 bit length (ex: 00000000000000040000000000000007)

edited
fabrice

The output of expw is 128 bits (=16 bytes).
The difference between exp and expw is the same as the difference between mul and mulw.

I guess 00000000000000040000000000000007 is in hexadecimal. If yes, this is 128 bits = 16 bytes.
So this cannot be represented by an uint64. If this was the output of expw, one of the output of expw would be 4, the other 7.

hungpq

Ok i’ll tell you more detail
I’m writing Log in contract. Are there any best practice for this? As i know log only accept log for 1 bytes. So i have to put all parametters in a single bytes. Thats why i asked this question.
For example with the question i ask, i want to log the value 00000000000000040000000000000007 To express the 2 value 4 and 7. So the log-reader can understand it is 2 params, each 64 bit.
So i think the question here should be how to express 2 uint64 in a single bytes?

hungpq

And speaking of log, i read this in the docs (Opcodes - Algorand Developer Portal) that have the limit MaxLogCalls params.
Could you tell me more about this limit, is that max number of log in a transaction. or an application only can log MaxLogCalls time, then it can not emit log anymore?

edited
hungpq

Thanks Ben for your answer. it help me a lot
what i want to ask here is Up to 32 times, up to 1024 bytes in a single transaction/1 application call. or it is a limit forever in an application. it can log up to 32 times for entire life cycle of its. no matter in how many transactions call to its application?