30件ヒット
[1-30件を表示]
(0.111秒)
検索結果
先頭4件
-
Float
# round(ndigits = 0) -> Integer | Float (18316.0) -
自身ともっとも近い整数もしくは実数を返します。
...ません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小数点以下を四捨五入し、整数を返します。
ndigitsが0より大きいならば、小数点以下の指定された位で四捨五入されます。
ndigitsが0より小さい......ndigitsが0より大きいならば、実数を返します。
ndigitsが0より小さいならば、整数を返します。
@raise TypeError ndigits で指定されたオブジェクトが整数に変換できない場
合発生します。
//emlist[例][ruby]{
1.0.round......1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1
t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-2) # => 93600
t.round(-3)... -
Float
# round(ndigits = 0 , half: :up) -> Integer | Float (18316.0) -
自身ともっとも近い整数もしくは実数を返します。
...ません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小数点以下を四捨五入し、整数を返します。
ndigitsが0より大きいならば、小数点以下の指定された位で四捨五入されます。
ndigitsが0より小さい......ndigitsが0より大きいならば、実数を返します。
ndigitsが0より小さいならば、整数を返します。
@raise TypeError ndigits で指定されたオブジェクトが整数に変換できない場
合発生します。
//emlist[例][ruby]{
1.0.round......1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1
t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-2) # => 93600
t.round(-3)... -
Float
# round(ndigits = 0) -> Integer | Float (18279.0) -
自身ともっとも近い整数もしくは実数を返します。
...ません。
@param ndigits 丸める位を指定します。
ndigitsが0ならば、小数点以下を四捨五入し、整数を返します。
ndigitsが0より大きいならば、小数点以下の指定された位で四捨五入されます。
ndigitsが0より小さい......ndigitsが0より大きいならば、実数を返します。
ndigitsが0より小さいならば、整数を返します。
@raise TypeError ndigits で指定されたオブジェクトが整数に変換できない場
合発生します。
//emlist[例][ruby]{
1.0.round......1.2.round # => 1
(-1.2).round # => -1
(-1.5).round # => -2
t = Math::PI # => 3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1
t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-2) # => 93600
t.round(-3)... -
bigdecimal (6096.0)
-
bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。
...bigdecimal は浮動小数点数演算ライブラリです。
任意の精度で 10 進表現された浮動小数点数を扱えます。
//emlist[][ruby]{
require 'bigdecimal'
a = BigDecimal("0.123456789123456789")
b = BigDecimal("123456.78912345678", 40)
print a + b # => 0.123456912580245903456......ASE は大きいほど都合がよいわけですが、デバッグのやりやすさなどを考慮して、
10000になっています (BASE は VpInit() 関数で自動的に計算します)。
これは 32 ビット整数の場合です。64ビット整数の場合はもっと大きな値にな......ます。
: add, sub, mult, div
これらのメソッドは先頭 (最左) の数字からの桁数を指定できます。
//emlist[][ruby]{
require "bigdecimal"
p BigDecimal("2").div(3, 12).to_s(10) # 2.0 / 3.0
# => 0.6666666666 67e0
//}
: truncate, round, ceil, floor
これらのメソ...