Ric*_*ram 2 ruby floating-point numbers rounding
目前我的代码呈现数字:
x = 0.000092627861766
p x
Run Code Online (Sandbox Code Playgroud)
像 BigInt 格式这样的东西:
=> 9.0e-05
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以调用变量来返回一个舍入的浮点数(以数字或字符串格式),使得:
x.some_method
# Always show N number of digits after the initial decimal point.
=> 0.00009263
OR
=> "0.00009263"
Run Code Online (Sandbox Code Playgroud)