如何计算Bitcoin/GBP的汇率?
How would calculate the exchange rate of Bitcoin/GBP?
我有一个 API returns 的值:USD/Bitcoin & USD/GBP.
{"USDBITCOIN":"4251.27", "USDGBP":"0.758659"}
为了计算 GBP/Bitcoin 的汇率,我简单地将英镑的价值除以比特币,因为它们都是基于美元的。
如何计算Bitcoin/GBP的汇率?它可能真的很简单,但它真的让我感到莫名其妙。我有下面的计算
app.js
xOfy(unit, value) {
return unit / value;
}
yOfX(unit, value) {
return unit * value;
}
xOfy(gbp, bitcoin)
// 0.00018
yOfx(bitcoin, gbp)
// 3225.26
您只需将 1 除以结果值:
1 / (USDGBP * USDBITCOIN)
在这种情况下,那就是:
1 / (0.758659 * 4251.27) = 0.0003100521146296338
1 本身来自于 4251.27 美元是 1 个比特币的价值。
为了计算每英镑的比特币,您只需使用每英镑的美元除以每比特币的美元。鉴于:
- 美元兑英镑为
0.758659
和
- 每个比特币的美元是
4251.27
…那么每英镑的比特币可以用以下分数表示:0.758659 ÷ 4251.27
.
一点点算术将有助于解释这一点。只是 运行 代码片段,因此 MathJax 将绘制公式来描述上面的计算:
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML&dummy=.js"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\(','\)']]} }); </script>
<p>Given the following conversion rates:</p>
\[
\require{cancel}
\begin{aligned}
\frac{\mathrm{USD}}{\mathrm{Bitcoin}} & = 4251.27
\~\
\frac{\mathrm{USD}}{\mathrm{GBP}} & = 0.758659
\end{aligned}
\]
<p>So, if you want to compute GBP per bitcoin, you will need this mathematical transformation:</p>
\[
\require{cancel}
\begin{aligned}
\frac{\mathrm{Bitcoin}}{\mathrm{GBP}}
& = \frac{\mathrm{Bitcoin}}{\cancel{\mathrm{USD}}} \times \frac{\cancel{\mathrm{USD}}}{\mathrm{GBP}} \
& = \frac{\mathrm{Bitcoin}}{\mathrm{USD}} \times \frac{\mathrm{USD}}{\mathrm{GBP}} \
& = \frac{1}{\frac{\mathrm{Bitcoin}}{\mathrm{USD}}} \times \frac{\mathrm{USD}}{\mathrm{GBP}} \
& = \frac{1}{4251.27} \times 0.758659 \
& = \frac{0.758659}{4251.27} \
& = 0.00017848
\end{aligned}
\]
我有一个 API returns 的值:USD/Bitcoin & USD/GBP.
{"USDBITCOIN":"4251.27", "USDGBP":"0.758659"}
为了计算 GBP/Bitcoin 的汇率,我简单地将英镑的价值除以比特币,因为它们都是基于美元的。
如何计算Bitcoin/GBP的汇率?它可能真的很简单,但它真的让我感到莫名其妙。我有下面的计算
app.js
xOfy(unit, value) {
return unit / value;
}
yOfX(unit, value) {
return unit * value;
}
xOfy(gbp, bitcoin)
// 0.00018
yOfx(bitcoin, gbp)
// 3225.26
您只需将 1 除以结果值:
1 / (USDGBP * USDBITCOIN)
在这种情况下,那就是:
1 / (0.758659 * 4251.27) = 0.0003100521146296338
1 本身来自于 4251.27 美元是 1 个比特币的价值。
为了计算每英镑的比特币,您只需使用每英镑的美元除以每比特币的美元。鉴于:
- 美元兑英镑为
0.758659
和 - 每个比特币的美元是
4251.27
…那么每英镑的比特币可以用以下分数表示:0.758659 ÷ 4251.27
.
一点点算术将有助于解释这一点。只是 运行 代码片段,因此 MathJax 将绘制公式来描述上面的计算:
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML&dummy=.js"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\(','\)']]} }); </script>
<p>Given the following conversion rates:</p>
\[
\require{cancel}
\begin{aligned}
\frac{\mathrm{USD}}{\mathrm{Bitcoin}} & = 4251.27
\~\
\frac{\mathrm{USD}}{\mathrm{GBP}} & = 0.758659
\end{aligned}
\]
<p>So, if you want to compute GBP per bitcoin, you will need this mathematical transformation:</p>
\[
\require{cancel}
\begin{aligned}
\frac{\mathrm{Bitcoin}}{\mathrm{GBP}}
& = \frac{\mathrm{Bitcoin}}{\cancel{\mathrm{USD}}} \times \frac{\cancel{\mathrm{USD}}}{\mathrm{GBP}} \
& = \frac{\mathrm{Bitcoin}}{\mathrm{USD}} \times \frac{\mathrm{USD}}{\mathrm{GBP}} \
& = \frac{1}{\frac{\mathrm{Bitcoin}}{\mathrm{USD}}} \times \frac{\mathrm{USD}}{\mathrm{GBP}} \
& = \frac{1}{4251.27} \times 0.758659 \
& = \frac{0.758659}{4251.27} \
& = 0.00017848
\end{aligned}
\]