Hi, I want to convert from Nat to Int. How do I do this?
I assume you are asking about Motoko.
Nat
is a subtype of Int
, so you don’t even have to explicitly convert – you can just use any value or expression of type Nat
in places where an Int
is expected.
1 Like
In motoko, How to convert Int to Nat ?
For example
let currentTime : Int = Time.now();
As the currentTime return Int type and we can assign the time to Nat variable or convert Int to Nat
You can use Int.abs()
from the base library.
3 Likes