るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

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

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

...れた整数であると解釈して、整数に変換します。

//emlist[例][ruby]{
p " 10".to_i # => 10
p "+10".to_i # => 10
p "-10".to_i # => -10

p "010".to_i # => 10
p "-010".to_i # => -10
//}

整数とみなせない文字があればそこまでを変換対象とします...
...0".to_i(0) # => 2
p "0o10".to_i(0) # => 8
p "010".to_i(0) # => 8
p "0d10".to_i(0) # => 10
p "0x10".to_i(0) # => 16
//}

@param base 進数を指定する整数。0 か、2〜36 の整数。
@return 整数

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

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

NEWS for Ruby 3.0.0 (78.0)

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

...wait(io, events, timeout)` in a non-blocking execution context. 16786
* Kernel
* Kernel#clone when called with the `freeze: false` keyword will call `#initialize_clone` with the `freeze: false` keyword. 14266
* Kernel#clone when called with the `freeze: true` keyword will call `#initialize...
...subclasses.
* Method inlining support for some C methods
* `Kernel`: `#class`, `#frozen?`
* `Integer`: `#-@`, `#~`, `#abs`, `#bit_length`, `#even?`, `#integer?`, `#magnitude`, `#odd?`, `#ord`, `#to_i`, `#to_int`, `#zero?`
* `Struct`: reader methods for 10th or later membe...
...tinuously improve the coverage of language features, analysis performance, and usability.

//emlist[][ruby]{
# test.rb
def foo(x)
if x > 10
x.to_s
else
nil
end
end

foo(42)
//}

//emlist{
$ typeprof test.rb
# Classes
class Object
def foo : (Integer) -> String?
end
//}

== Miscellaneo...

String#hex -> Integer (30.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 (30.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_f -> Float (30.0)

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

...# => Infinity
# warning: Float 10101010101010101010... out of range
//}

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

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

絞り込み条件を変える

bigdecimal (30.0)

bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。

...) #=> Infinity
BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity
//}

無限大を表す BigDecimal オブジェクトを作成する場合、
Kernel
.#BigDecimal の引数に "Infinity" や "-Infinity" を指定して
ください。(大文字小文字を区別します)

//emlist[][ruby]{
requ...
...2").div(3, 12).to_s(10) # 2.0 / 3.0
# => 0.6666666666 67e0
//}

: truncate, round, ceil, floor

これらのメソッドは小数点からの相対位置を指定して桁数を決定します。

//emlist[][ruby]{
require "bigdecimal"
p BigDecimal("6.66666666666666").round(12).to_s(10)
# => 0.666...
...k,sig)
pi = pi + u
k = k + two
end
pi
end

if $0 == __FILE__
if ARGV.size == 1
puts "PI("+ARGV[0]+"):"
puts big_pi(ARGV[0].to_i)
else
puts "TRY: ruby pi.rb 1000"
end
end
//}

=== その他

以下のメソッド以外にも、(C ではない) Ruby ソースの形で...