るりまサーチ

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#to_f -> Float (39119.0)

self を浮動小数点数(Float)に変換します。

...self を浮動小数点数(Float)に変換します。

self が Float の範囲に収まらない場合、Float::INFINITY を返します。

//emlist[][ruby]{
1.to_f # => 1.0
(Float::MAX.to_i * 2).to_f # => Infinity
(-Float::MAX.to_i * 2).to_f # => -Infinity
//}...

String#to_f -> Float (18185.0)

文字列を 10 進数表現と解釈して、浮動小数点数 Float に変換します。

...by]{
p "-10".to_f # => -10.0
p "10e2".to_f # => 1000.0
p "1e-2".to_f # => 0.01
p ".1".to_f # => 0.1

p "1_0_0".to_f # => 100.0 # 数値リテラルと同じように区切りに _ を使える
p " \n10".to_f # => 10.0 # 先頭の空白・改行は無視される
p "7xa.5".to_f # => 7.0
//}...
...します。
変換対象が空文字列のケースでも、0.0 を返します。

//emlist[][ruby]{
p "".to_f # => 0.0
p "nan".to_f # => 0.0
p "INF".to_f # => 0.0
p "-Inf".to_f # => 0.0
//}

変換後の Float が有限の値を取れないときは、Float::INFINITY を用います。...
...1000).to_f # => Infinity
# warning: Float 10101010101010101010... out of range
//}

なお、このメソッドとは逆に、数値を文字列に変換するには
Kernel.#sprintf, String#%, Integer#to_s
を使用します。

@see String#hex, String#oct, String#to_i,
Kernel.#Integer, Kern...

Socket::Constants::IPPROTO_FRAGMENT -> Integer (6201.0)

IPv6 fragmentation header。 BasicSocket#getsockopt, BasicSocket#setsockopt の level 引数に使用します。

IPv6 fragmentation header。
BasicSocket#getsockopt, BasicSocket#setsockopt の
level 引数に使用します。

また、Socket.open の protocol 引数に渡す利用法もあります。

@see 2292

Socket::IPPROTO_FRAGMENT -> Integer (6201.0)

IPv6 fragmentation header。 BasicSocket#getsockopt, BasicSocket#setsockopt の level 引数に使用します。

IPv6 fragmentation header。
BasicSocket#getsockopt, BasicSocket#setsockopt の
level 引数に使用します。

また、Socket.open の protocol 引数に渡す利用法もあります。

@see 2292

BigDecimal#split -> [Integer, String, Integer, Integer] (315.0)

BigDecimal 値を 0.xxxxxxx*10**n と表現したときに、 符号 (NaNのときは 0、それ以外は+1か-1になります)、 仮数部分の文字列("xxxxxxx")と、基数(10)、更に指数 n を配列で返します。

..."
a = BigDecimal("3.14159265")
f, x, y, z = a.split
//}

とすると、f = 1、x = "314159265"、y = 10、z = 1 になります。
従って、以下のようにする事で Float に変換することができます。

//emlist[][ruby]{
s = "0."+x
b = f*(s.to_f)*(y**z)
//}

@see BigDecimal#to_f...

絞り込み条件を変える

BigDecimal#round -> Integer (125.0)

クラスメソッド BigDecimal.mode(BigDecimal::ROUND_MODE,flag) で指定した BigDecimal::ROUND_MODE に従って丸め操作を実行します。

...に少なくとも n 個の 0 が並びます)。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(4).to_f # => 1.2346
BigDecimal("15.23456").round(-1).to_f # => 20.0
//}

2番目の引数を指定すると、BigDecimal.mode の指定を無視して、指定さ
れた方法で...
...丸め操作を実行します。

//emlist[][ruby]{
require "bigdecimal"
BigDecimal("1.23456").round(3,BigDecimal::ROUND_HALF_EVEN).to_f # => 1.235
require "bigdecimal"
BigDecimal("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN).to_f # => 1.234
//}

@see BigDecimal.mode...

String#hex -> Integer (119.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...# => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

@see String#oct, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#Float

このメソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
Integer
#to_s
などを使ってください。...

String#oct -> Integer (119.0)

文字列を 8 進文字列であると解釈して、整数に変換します。

...{
p "-010".oct # => -8
p "-0x10".oct # => -16
p "-0b10".oct # => -2

p "1_0_1x".oct # => 65
//}

@see String#hex, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#Float

逆に、数値を文字列に変換するにはKernel.#sprintf,
String#%, Integer#to_s を使用します。...

String#to_i(base = 10) -> Integer (119.0)

文字列を 10 進数表現された整数であると解釈して、整数に変換します。

...する整数。0 か、2〜36 の整数。
@return 整数

このメソッドの逆に数値を文字列に変換するには、
Kernel.#sprintf, String#%, Integer#to_s
を使用します。

String#hex, String#oct, String#to_f,
Kernel.#Integer, Kernel.#Float
も参照してください。...

Time#nsec -> Integer (114.0)

時刻のナノ秒の部分を整数で返します。

...す。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p "%10.9f" % t.to_f # => "946749845.000005960"
p t.nsec # => 6000
//}

IEEE 754 浮動小数点数で表現できる精度が違うため、Time#to_fの最小
の桁とnsecの最小の桁は異なります。nsecで表され...

絞り込み条件を変える

<< 1 2 3 ... > >>