I'm trying to calculate a value of token by using division operator, it will return a number higher then 1, but never returns here is the code of the price calculation:
#[ink(message)]
pub fn get_price_for_token_a_as_input(&self) -> Balance {
let pool_b_amount: Balance = self.token_b.balance_of(self.get_account_id());
let opr:Balance = 10;
let one = 1*opr.pow(12);
let price_from_one_token_a_to_b = one (1) / pool_b_amount (200);
price_from_one_token_a_to_b
}
The Value of price_from_one_token_a_to_b
is always 0.
the values are already 10^12.
Thanks in advance.
pool_b_amount
? What is the expected number you want to get given that value?pool_b_amount
to make sure it is200
and not200e12
.