るりまサーチ

最速Rubyリファレンスマニュアル検索!
55件ヒット [1-55件を表示] (0.031秒)
トップページ > クエリ:float[x] > クエリ:>[x] > クエリ:hex[x]

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

String#hex -> Integer (18255.0)

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

...ist[例][ruby]{
p "10".hex # => 16
p "ff".hex # => 255
p "0x10".hex # => 16
p "-0x10".hex # => -16

p "xyz".hex # => 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

このメソッドの...

String#to_f -> Float (247.0)

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

... Float に変換します。

浮動小数点数とみなせなくなるところまでを変換対象とします。
途中に変換できないような文字列がある場合、それより先の文字列は無視されます。

//emlist[][ruby]{
p "-10".to_f # => -10.0
p "10e2".to_f # => 10...
...00.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
//}

以下の例は、先頭に浮動小数点数とみ...
...# => 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...

String#oct -> Integer (112.0)

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

...by]{
p "10".oct # => 8
p "010".oct # => 8
p "8".oct # => 0
//}

oct は文字列の接頭辞 ("0", "0b", "0B", "0x", "0X") に応じて
8 進以外の変換も行います。

//emlist[例][ruby]{
p "0b10".oct # => 2
p "10".oct # => 8
p "010".oct # => 8
p "0x10".oct # => 16
//}

整数と...
...対象になります。

//emlist[例][ruby]{
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,
S...

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

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

...=> 10
p "+10".to_i # => 10
p "-10".to_i # => -10

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

整数とみなせない文字があればそこまでを変換対象とします。
変換対象が空文字列であれば 0 を返します。

//emlist[例][ruby]{
p "0x11".to_i # =>...
...> 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
も参照してください。...

ruby 1.6 feature (108.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...になります。

((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。

== 1.6.8 (2002-12-24) -> stable-snapshot

: 2003-01-22: errno

EAGAIN と EWOULDBLOCK が同じ値のシステムで、EWOUL...
...=> ruby 1.6.7 (2002-03-01) [i586-linux]
"foo"

: ((<time>)), URI

追加されました。

: Ruby/Tk

バグ修正、機能追加 ((<ruby-dev:16139>)),((<ruby-dev:16153>))。

: 数値リテラルの `_'

`_' を置ける場所の規則が見直され、String#hex など...
...=> ruby 1.6.5 (2001-09-19) [i586-linux]
NotImplementedError
MatchData
Exception
Numeric
MatchData
Segmentation fault

=> ruby 1.6.5 (2001-10-15) [i586-linux]
MatchData
NotImplementedError
Float
...

絞り込み条件を変える