Hi everybody,
I have a problem in a Smart Contract: because of some operations, I could have some negative values, so, to avoid this problem, for any operations, like x = v1-h I want the absolute value. So, using the function globalput and globalget, I tried this:
If(Lt(v1, h),
App.globalPut(Bytes("negative"), Bytes("1")),
App.globalPut(Bytes("negative"), Bytes("0"))
)
negative = App.globalGet(Bytes("negative"))
If(Eq(negative, Bytes("1")),
App.globalPut(Bytes("x"), h - v1),
App.globalPut(Bytes("x"), v1 - h)
)
x = App.globalGet(Bytes("x"))
Where I check h = 1581 and v1 = 0, but negative = 0.
I tried this with Int(1) and Int(0) too instead of Bytes(“1”) and Bytes(“0”).
What’s the problem?
