我无法计算PostgreSQL中的% 在我的代码下方
let url = URL(string: "https://mywebsite.co.uk/loginarea.php?link=\(answer)")!
答案得到0和100而不是60%
答案 0 :(得分:1)
投射为numeric
的值
SELECT ROUND(( 3::NUMERIC/5::NUMERIC ) * 100);
答案 1 :(得分:0)
如果需要浮点结果,则应在计算中至少使用一个浮点数,这样整个表达式都将升为浮点数:
error[E0502]: cannot borrow `*self` as immutable because it is also borrowed as mutable
--> src/main.rs:27:30
|
23 | let account = self.accounts.get_mut(id).unwrap();
| ------------- mutable borrow occurs here
...
27 | account.set(balance, self);
| --- ^^^^ immutable borrow occurs here
| |
| mutable borrow later used by call