Trying to do this: new_fee: val.as_u256() * 10.as_u256() ** expo.as_u256()
but getting an error: No method named "pow" found for type "u256"
, is pow
not supported for u256
? or am I using the wrong syntax?
I’ve also tried variants like:
val.as_u256() * 10.as_u256().pow(expo.as_u256())
val.as_u256() * u256::from(10).pow(expo.as_u256())
and they all don’t work
Since u256
is special in the sense that they cannot fit into the primative 64 bit registers they are treated slightly differently.
Read more here:
https://fuellabs.github.io/sway/v0.54.0/book/reference/solidity_differences.html?highlight=word%20siz#word-size
However using the power function, logarithm, square roots they all depend on the math library inside the standard library like so:
1 Like
thanks for the context! managed to get it working by importing
use std::math::*;
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.