るりまサーチ

最速Rubyリファレンスマニュアル検索!
116件ヒット [1-100件を表示] (0.020秒)

別のキーワード

  1. _builtin float
  2. float to_d
  3. float rationalize
  4. json float
  5. fiddle type_float

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Float#round(ndigits = 0) -> Integer | Float (27330.0)

自身ともっとも近い整数もしくは実数を返します。

...]{
1.0.round # => 1
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) # => 94000
t.round(-100) # => 0

2.5.round(half: :up) # => 3
2.5.round(half: :even) # => 2
2.5.round(half: :down) # => 2
3.5.round(half: :up) # => 4
3.5.round(half: :even) # => 4
3.5.round(half: :down) # => 3
//}

@see Float#ceil, Float#floor, Float#truncate...

Float#round(ndigits = 0, half: :up) -> Integer | Float (27330.0)

自身ともっとも近い整数もしくは実数を返します。

...]{
1.0.round # => 1
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) # => 94000
t.round(-100) # => 0

2.5.round(half: :up) # => 3
2.5.round(half: :even) # => 2
2.5.round(half: :down) # => 2
3.5.round(half: :up) # => 4
3.5.round(half: :even) # => 4
3.5.round(half: :down) # => 3
//}

@see Float#ceil, Float#floor, Float#truncate...

Float#round(ndigits = 0) -> Integer | Float (27292.0)

自身ともっとも近い整数もしくは実数を返します。

...]{
1.0.round # => 1
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) # => 94000
t.round(-100) # => 0
//}

@see Float#ceil, Float#floor, Float#truncate...

Integer#round(ndigits = 0, half: :up) -> Integer | Float (18292.0)

self ともっとも近い整数を返します。

...

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返...
...]{
1.round # => 1
1.round(2) # => 1.0
15.round(-1) # => 20
(-15).round(-1) # => -20

25.round(-1, half: :up) # => 30
25.round(-1, half: :down) # => 20
25.round(-1, half: :even) # => 20
35.round(-1, half: :up) # => 40
35.round(-1, half: :down) # => 30
35.round(-1,...
...half: :even) # => 40
(-25).round(-1, half: :up) # => -30
(-25).round(-1, half: :down) # => -20
(-25).round(-1, half: :even) # => -20
//}

@see Numeric#round...

Matrix#round(ndigits = 0) -> Matrix (18113.0)

行列の各要素を指定した桁数で丸めた行列を返します。

...行列の各要素を指定した桁数で丸めた行列を返します。

@see Float#round...

絞り込み条件を変える

Float::ROUNDS -> Integer (15100.0)

この定数は Ruby 2.7 から deprecated です。使わないでください。

この定数は Ruby 2.7 から deprecated です。使わないでください。


丸めモード (-1: 不定、0: 0.0 の方向に丸め、1: 四捨五入、2:正の無限
大の方向に丸め、3:負の無限大の方向に丸め)です。

Float#ceil(ndigits = 0) -> Integer | Float (9131.0)

自身と等しいかより大きな整数のうち最小のものを返します。

...

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返...
...34567.89.ceil(-4) # => 40000
34567.89.ceil(-3) # => 35000
34567.89.ceil(-2) # => 34600
34567.89.ceil(-1) # => 34570
34567.89.ceil(0) # => 34568
34567.89.ceil(1) # => 34567.9
34567.89.ceil(2) # => 34567.89
34567.89.ceil(3) # => 34567.89
//}

@see Float#floor, Float#round, Float#truncate...

Float#floor(ndigits = 0) -> Integer | Float (9119.0)

自身と等しいかより小さな整数のうち最大のものを返します。

...

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返...
...oor(-4) # => 30000
34567.89.floor(-3) # => 34000
34567.89.floor(-2) # => 34500
34567.89.floor(-1) # => 34560
34567.89.floor(0) # => 34567
34567.89.floor(1) # => 34567.8
34567.89.floor(2) # => 34567.89
34567.89.floor(3) # => 34567.89
//}

@see Numeric#ceil, Numeric#round, Float#truncate...

Float#truncate(ndigits = 0) -> Integer | Float (9113.0)

小数点以下を切り捨てて値を整数に変換します。

...

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返...
...す。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
1.234567.truncate(2) # => 1.23
34567.89.truncate(-2) # => 34500
//}

@see Numeric#round, Numeric#ceil, Numeric#floor...

Float#ceil -> Integer (9024.0)

自身と等しいかより大きな整数のうち最小のものを返します。

...自身と等しいかより大きな整数のうち最小のものを返します。


//emlist[例][ruby]{
1.2.ceil # => 2
2.0.ceil # => 2
(-1.2).ceil # => -1
(-2.0).ceil # => -2
//}

@see Float#floor, Float#round, Float#truncate...

絞り込み条件を変える

Float#to_i -> Integer (9013.0)

小数点以下を切り捨てて値を整数に変換します。

...

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返...
...す。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
1.234567.truncate(2) # => 1.23
34567.89.truncate(-2) # => 34500
//}

@see Numeric#round, Numeric#ceil, Numeric#floor...

Float#floor -> Integer (9012.0)

自身と等しいかより小さな整数のうち最大のものを返します。

...自身と等しいかより小さな整数のうち最大のものを返します。


//emlist[例][ruby]{
1.2.floor # => 1
2.0.floor # => 2
(-1.2).floor # => -2
(-2.0).floor # => -2
//}

@see Numeric#ceil, Numeric#round, Float#truncate...

Float#to_i -> Integer (9006.0)

小数点以下を切り捨てて値を整数に変換します。

...小数点以下を切り捨てて値を整数に変換します。


//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}

@see Numeric#round, Numeric#ceil, Numeric#floor...

Float#truncate -> Integer (9006.0)

小数点以下を切り捨てて値を整数に変換します。

...小数点以下を切り捨てて値を整数に変換します。


//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}

@see Numeric#round, Numeric#ceil, Numeric#floor...

Numeric#floor(ndigits = 0) -> Integer | Float (113.0)

自身と等しいかより小さな整数のうち最大のものを返します。

...

@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返...
...します。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[例][ruby]{
1.floor #=> 1
1.2.floor #=> 1
(-1.2).floor #=> -2
(-1.5).floor #=> -2
//}

@see Numeric#ceil, Numeric#round, Numeric#truncate
@see Integer#floor...

絞り込み条件を変える

Numeric (100.0)

数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。

...数値を表す抽象クラスです。Integer や Float などの数値クラス
は Numeric のサブクラスとして実装されています。

演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッ...
...ださい。


=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Numeric Integer Fixnum Bignum Float Rational Complex
-------------------------------------------------------------------------------------------...
...- - - o
remainder | o - - o - - -
round
| o o - - o o -
singleton_method_added | o - -...
...を参照してください。


=> ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]
Numeric Integer Float Rational Complex
--------------------------------------------------------------------------------
% | o...
...r Float Rational Complex
--------------------------------------------------------------------------------
rectangular | o - - - o
remainder | o o - - -
round
...

NEWS for Ruby 2.4.0 (66.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...090

* File
* File.empty? を追加 9969

* Float
* Float#ceil, Float#floor, Float#truncate は
Float
#roundと同じように省略可能な桁を指定する引数を受け付けるようになりました。12245
* Float#round は half というキーワード引数を受け...
...ncate は
Integer#round と同じように省略可能な桁を指定する引数を受け付けるようになりました 12245
* Integer#digits を追加。 12447
位置記法のために各桁を展開するためのメソッドです。
* Integer#round は half というキ...
...ational
* Rational#round は half というキーワード引数を受け付けるようになりました。12548 12958
half には :even, :up, :down が指定可能です。12953

* Regexp
* meta character \X matches Unicode 9.0 characters with some workarounds
for UTR #51 Un...
<< 1 2 > >>