# Getting 10% of tez

Hi, I'm writing a smart contract in Michelson, and I can't figure out how to get 10% of a tez amount. According to the language.pdf doc on Michelson, there are only these operators on tez: ADD, SUB, MUL, and COMPARE.

• ADD: :: tez : tez : 'S -> tez : 'S
• SUB: :: tez : tez : 'S -> tez : 'S
• MUL :: tez : u?int{8|16|32|64} : 'S -> tez : 'S
• COMPARE: :: tez : tez : 'S -> int64 : 'S

So it looks like I want to use MUL on a stack that looks like [ tez : 0.10], but 0.10 isn't an int, so I can't use that.

If I try to do MUL [tez : tez] where the second tez is "0.10", I get "operator MUL is undefined between tez and tez"

I saw that DIV existed as well, but if I do DIV [tez: tez], I get "operator DIV is undefined between tez and tez"

If I do DIV [tez: uint32] I get "operator DIV is undefined between tez and uint32"

It looks like the only thing I can do is:

PUSH uint32 10; PUSH uint32 1; DIV;

But that seems pretty convoluted, and I'm pretty sure that the result of int division should only be an int.

Any help would be appreciated, thanks!

edit retag close delete

Sort by ยป oldest newest most voted

Yes, it's totally missing, thank you for noticing! We're redoing the integers to use libgmp everywhere; tere will be only three int types: int, nat, and tez. But before we do we should still fix this.

If you're feeling adventurous and want to send us a patch, take a look at Mul_tez in the code

https://github.com/tezos/te...

You can add Div_tez is a couple lines by replicating this pattern.

more

Cool! I'll look into sending a patch. Thanks for the response!

( 2017-05-13 23:28:01 -0600 )edit