本文簡要介紹ruby語言中 String.to_d
的用法。
用法
to_d → bigdecimal
返回將 str
中的前導字符解釋為 BigDecimal
的結果。
require 'bigdecimal'
require 'bigdecimal/util'
"0.5".to_d # => 0.5e0
"123.45e1".to_d # => 0.12345e4
"45.67 degrees".to_d # => 0.4567e2
另見 BigDecimal::new
。
相關用法
- Ruby String.to_sym用法及代碼示例
- Ruby String.to_i用法及代碼示例
- Ruby String.to_c用法及代碼示例
- Ruby String.to_f用法及代碼示例
- Ruby String.to_r用法及代碼示例
- Ruby String.tr用法及代碼示例
- Ruby String.tr_s用法及代碼示例
- Ruby String.match?用法及代碼示例
- Ruby String.unpack用法及代碼示例
- Ruby String.scan用法及代碼示例
- Ruby String.dump用法及代碼示例
- Ruby String.oct用法及代碼示例
- Ruby String.size用法及代碼示例
- Ruby String.scrub用法及代碼示例
- Ruby String.chop用法及代碼示例
- Ruby String.bytesize用法及代碼示例
- Ruby String.count用法及代碼示例
- Ruby String.string <=>用法及代碼示例
- Ruby String.ascii_only?用法及代碼示例
- Ruby String.downcase用法及代碼示例
- Ruby String.capitalize用法及代碼示例
- Ruby String.length用法及代碼示例
- Ruby String.lines用法及代碼示例
- Ruby String.unicode_normalize用法及代碼示例
- Ruby String.center用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 String.to_d。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。