るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Float#%(other) -> Float (39215.0)

算術演算子。剰余を計算します。

...算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)

//emlist[例][ruby]{
# 剰余
3.0 % 1.2 # => 0.6000000000000001
3.0 % 0.0 # ZeroDivisionError
//}...

Float#next_float -> Float (27311.0)

浮動小数点数で表現可能な self の次の値を返します。

...します。

Float
::MAX.next_floatFloat::INFINITY.next_float
Float
::INFINITY を返します。Float::NAN.next_float
Float
::NAN を返します。

//emlist[例][ruby]{
p 0.01.next_float # => 0.010000000000000002
p 1.0.next_float # => 1.0000000000000002
p 100.0.next_float # => 100.000...
...00000000001

p 0.01.next_float - 0.01 # => 1.734723475976807e-18
p 1.0.next_float - 1.0 # => 2.220446049250313e-16
p 100.0.next_float - 100.0 # => 1.4210854715202004e-14

f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.next_float }
# => 0x1.47ae147ae147bp-7 0.01
# 0x1.47ae147ae14...
...47ae147ae1489p-7 0.010000000000000024
# 0x1.47ae147ae148ap-7 0.010000000000000026
# 0x1.47ae147ae148bp-7 0.010000000000000028
# 0x1.47ae147ae148cp-7 0.01000000000000003
# 0x1.47ae147ae148dp-7 0.010000000000000031
# 0x1.47ae147ae148ep-7 0.010000000000000033
//}

@see Float#prev_float...

Float#prev_float -> Float (27311.0)

浮動小数点数で表現可能な self の前の値を返します。

...す。

(-Float::MAX).prev_float と (-Float::INFINITY).prev_float
は -Float::INFINITY を返します。Float::NAN.prev_float
Float
::NAN を返します。

//emlist[例][ruby]{
p 0.01.prev_float # => 0.009999999999999998
p 1.0.prev_float # => 0.9999999999999999
p 100.0.prev_float # => 99.9...
...9999999999999

p 0.01 - 0.01.prev_float # => 1.734723475976807e-18
p 1.0 - 1.0.prev_float # => 1.1102230246251565e-16
p 100.0 - 100.0.prev_float # => 1.4210854715202004e-14

f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.prev_float }
# => 0x1.47ae147ae147bp-7 0.01
# 0x1.47ae147a...
...47ae147ae146dp-7 0.009999999999999976
# 0x1.47ae147ae146cp-7 0.009999999999999974
# 0x1.47ae147ae146bp-7 0.009999999999999972
# 0x1.47ae147ae146ap-7 0.00999999999999997
# 0x1.47ae147ae1469p-7 0.009999999999999969
# 0x1.47ae147ae1468p-7 0.009999999999999967
//}

@see Float#next_float...

Float#modulo(other) -> Float (24115.0)

算術演算子。剰余を計算します。

...算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)

//emlist[例][ruby]{
# 剰余
3.0 % 1.2 # => 0.6000000000000001
3.0 % 0.0 # ZeroDivisionError
//}...

Float#**(other) -> Float (21108.0)

算術演算子。冪を計算します。

...算術演算子。冪を計算します。

@param other 二項演算の右側の引数(対象)

//emlist[例][ruby]{
# 冪
1.2 ** 3.0 # => 1.7279999999999998
3.0 + 4.5 - 1.3 / 2.4 * 3 % 1.2 ** 3.0 # => 5.875
0.0 ** 0 # => 1.0
//}...

絞り込み条件を変える

Float#divmod(other) -> [Numeric] (21007.0)

self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。

...: 0 <= r < other
* other < 0 のとき: other < r <= 0
* q は整数
をみたす数です。
このメソッドは、メソッド / と % によって定義されています。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
11.divmod(3) # => [3, 2]
(...

String#%(args) -> String (18263.0)

printf と同じ規則に従って args をフォーマットします。

...ist[例][ruby]{
p "i = %d" % 10 # => "i = 10"
p "i = %x" % 10 # => "i = a"
p "i = %o" % 10 # => "i = 12"

p "i = %#d" % 10 # => "i = 10"
p "i = %#x" % 10 # => "i = 0xa"
p "i = %#o" % 10 # => "i = 012"

p "%d" % 10 # => "10"
p "%d,%o" % [10, 10] # => "10,12...
...ないこと、2進数の指示子(%b, %B)が存在すること、sprintf のすべての方言をサ
ポートしていないこと(%': 3桁区切り)などの違いがあります。

Ruby には整数の大きさに上限がないので、%b, %B, %o, %x, %X
に負の数を与えると (左側に...
...るためには %+x、% x のように指定します。


以下は sprintf フォーマットの書式です。[] で囲まれた部分は省略可
能であることを示しています。

%
[nth$][フラグ][幅][.精度]指示子
%
[<name>][フラグ][幅][.精度]指示子

`%' 自身を出...

Bignum#%(other) -> Fixnum | Bignum | Float (18203.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

Fixnum#%(other) -> Fixnum | Bignum | Float (18203.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

Bignum#modulo(other) -> Fixnum | Bignum | Float (3103.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

絞り込み条件を変える

Fixnum#modulo(other) -> Fixnum | Bignum | Float (3103.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

Time#to_f -> Float (108.0)

起算時からの経過秒数を浮動小数点数で返します。1 秒に満たない経過も 表現されます。

...らの経過秒数を浮動小数点数で返します。1 秒に満たない経過も
表現されます。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p t # => 2000-01-02 03:04:05 +0900
p "%10.6f" % t.to_f # => "946749845.000006"
p t.to_i # => 946749845
//}...

Integer#**(other) -> Numeric (19.0)

算術演算子。冪(べき乗)を計算します。

...

@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します...
...-3
5.pow(2, -8) # => -7
//}

結果が巨大すぎる整数になりそうなとき、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定...
<< 1 2 > >>