4410件ヒット
[1-100件を表示]
(0.071秒)
別のキーワード
クラス
-
ARGF
. class (24) - Array (314)
- BasicObject (12)
- Binding (7)
- Complex (24)
- Data (3)
- Dir (35)
-
Encoding
:: Converter (48) - Enumerator (31)
- File (120)
-
File
:: Stat (204) - Float (112)
- Hash (36)
- IO (188)
- Integer (818)
- MatchData (82)
- Method (36)
- Module (24)
- Mutex (2)
- NilClass (12)
- Numeric (201)
- Object (102)
- Proc (24)
- Random (96)
- Range (28)
- Rational (84)
- Regexp (84)
- RubyVM (12)
-
RubyVM
:: AbstractSyntaxTree :: Node (28) -
RubyVM
:: InstructionSequence (12) - Set (9)
- SignalException (12)
- String (309)
- Struct (72)
- Thread (79)
-
Thread
:: Backtrace :: Location (12) -
Thread
:: Mutex (10) -
Thread
:: Queue (30) -
Thread
:: SizedQueue (10) - Time (293)
- TracePoint (12)
- UnboundMethod (48)
モジュール
- Enumerable (200)
- FileTest (12)
- GC (36)
- Kernel (271)
- Marshal (24)
- Math (36)
- ObjectSpace (48)
- Process (60)
キーワード
-
$ $ (12) -
$ . (12) -
$ SAFE (7) - % (24)
- & (12)
- * (12)
- ** (12)
- + (12)
- - (12)
- -@ (12)
-
/ (11) - < (12)
- << (21)
- <= (12)
- <=> (36)
- == (12)
- === (12)
- =~ (24)
- > (12)
- >= (12)
- >> (12)
- DEBUG (12)
- DEBUG= (12)
-
DEFAULT
_ PARAMS (12) -
MAJOR
_ VERSION (12) -
MINOR
_ VERSION (12) - Numeric (12)
- ROUNDS (7)
-
RUBY
_ PATCHLEVEL (12) -
RUBY
_ REVISION (6) - Rational (24)
- [] (36)
- []= (12)
- ^ (12)
-
_ _ id _ _ (12) - abs (12)
-
add
_ trace _ func (12) - all? (45)
- allbits? (8)
- any? (48)
- anybits? (8)
- arity (36)
- at (53)
- begin (12)
- binwrite (12)
-
bit
_ length (12) - blksize (12)
- blocks (12)
-
bsearch
_ index (20) - bytebegin (2)
- byteend (2)
- byteindex (3)
- byteoffset (6)
- byterindex (3)
- bytes (24)
- bytesize (12)
- ceil (48)
- ceildiv (3)
- chown (12)
- chr (36)
- class (12)
- classify (3)
- codepoints (24)
- coerce (12)
- compile (12)
- concat (18)
-
const
_ source _ location (12) -
copy
_ stream (24) - count (96)
- day (12)
- delete (12)
- denominator (48)
-
dev
_ major (12) -
dev
_ minor (12) - dig (9)
- digits (24)
- div (24)
- downto (24)
-
each
_ object (48) - end (12)
- even? (12)
- fcntl (12)
- fileno (23)
-
find
_ index (72) -
first
_ column (7) -
first
_ lineno (19) - floor (48)
- fork (24)
- format (12)
- frexp (12)
- gcd (12)
- gcdlcm (12)
- getbyte (24)
- gid (12)
-
gmt
_ offset (12) - gmtoff (12)
- groups (12)
- hash (123)
- hex (12)
- hour (12)
- index (48)
- ino (12)
- inspect (12)
- integer? (24)
-
last
_ column (7) -
last
_ lineno (7) - lchmod (12)
- lchown (12)
- lcm (12)
- length (73)
- lgamma (12)
- lineno (24)
- magnitude (12)
- max (10)
- mday (12)
- method (12)
- min (12)
- mode (12)
- modulo (12)
- mon (12)
- month (12)
-
named
_ captures (12) - new (31)
-
new
_ seed (12) - next (12)
- nlink (12)
- nobits? (8)
- nsec (12)
-
num
_ waiting (10) - numerator (36)
-
object
_ id (12) - oct (12)
- odd? (12)
- offset (24)
- one? (45)
- ord (24)
- owner (12)
- pack (21)
- pid (12)
- pos (24)
- pow (24)
- pred (12)
-
primitive
_ convert (48) - priority (12)
- priority= (12)
-
public
_ method (12) - putc (12)
- pwrite (8)
- rand (96)
- rationalize (24)
- rdev (12)
-
rdev
_ major (12) -
rdev
_ minor (12) - readbyte (24)
- real? (12)
- remainder (12)
-
reverse
_ each (4) - rindex (48)
- round (57)
-
safe
_ level (7) - sec (12)
- seed (12)
-
set
_ trace _ func (12) - setbyte (12)
- signo (12)
-
singleton
_ class (12) - size (133)
- size? (24)
- sleep (36)
-
sort
_ by (24) -
source
_ location (43) - spawn (48)
- sprintf (12)
- sqrt (20)
- srand (24)
- stat (24)
- step (93)
- subsec (12)
- succ (12)
- sum (54)
- syscall (12)
- sysopen (12)
- syswrite (12)
- tally (8)
- tell (24)
- test (24)
- times (24)
-
to
_ f (24) -
to
_ i (96) -
to
_ int (36) -
to
_ r (12) -
to
_ s (12) - truncate (48)
-
try
_ convert (4) -
tv
_ nsec (12) -
tv
_ sec (12) -
tv
_ usec (12) - uid (12)
- umask (24)
- unlink (12)
- unpack (12)
- upto (24)
- usec (12)
-
utc
_ offset (12) - utime (12)
-
values
_ at (12) - wait (12)
- wait2 (12)
- waitpid (12)
- waitpid2 (12)
- wday (12)
-
world
_ readable? (24) -
world
_ writable? (12) - write (36)
- yday (12)
- year (12)
- | (12)
- ~ (24)
検索結果
先頭5件
-
Integer
# integer? -> true (27127.0) -
常に真を返します。
...常に真を返します。
//emlist[][ruby]{
1.integer? # => true
1.0.integer? # => false
//}... -
Integer
. sqrt(n) -> Integer (21175.0) -
非負整数 n の整数の平方根を返します。すなわち n の平方根以下の 最大の非負整数を返します。
...。Integer ではない場合は、最初に Integer に変換されます。
@raise Math::DomainError n が負の整数の時に発生します。
//emlist[][ruby]{
Integer.sqrt(0) # => 0
Integer.sqrt(1) # => 1
Integer.sqrt(24) # => 4
Integer.sqrt(25) # => 5
Integer.sqrt(.......floor と同等ですが、後者は浮動小数点数の精度の限界によって
真の値とは違う結果になることがあります。
//emlist[][ruby]{
Integer.sqrt(10**46) #=> 100000000000000000000000
Math.sqrt(10**46).floor #=> 99999999999999991611392 (!)
//}
@see Math.#sqrt... -
Integer
. try _ convert(obj) -> Integer | nil (21167.0) -
obj を Integer に変換しようと試みます。変換には Object#to_int メソッドが使われます。
...obj を Integer に変換しようと試みます。変換には Object#to_int
メソッドが使われます。
Integer ならそのままobjを返します。
そうでなければ obj.to_int の結果を返すか、nil が返されます。
@param obj 変換する任意のオブジェクト......@return Integer または nil
@raise TypeError to_int が Integer を返さなかった場合に発生します。
//emlist[例][ruby]{
Integer.try_convert(1) # => 1
Integer.try_convert(1.25) # => 1
Integer.try_convert([]) # => nil
//}... -
Integer
# div(other) -> Integer (21151.0) -
整商(整数の商)を返します。 普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。
...整商とします。
other が Integer オブジェクトの場合、Integer#/ の結果と一致します。
div に対応する剰余メソッドは modulo です。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
7.div(2) # => 3
7.div(-2) # => -4......=> 3
begin
2.div(0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
begin
2.div(0.0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
# Integer#/ と違い、引数が Float でもゼロで割ることはできない
end
//}
@see Integer#fdiv, Integer#/, Integer#modulo... -
Integer
# [](nth) -> Integer (21141.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...lf[..j] で n & ((1 << (j + 1)) - 1) が 0 以外のとき
@raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき
//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010
a = 9**15
50.downto(0) {|n| print a[n] }
# => 000101110......01
//}
n[i] は (n >> i) & 1 と等価なので、負のインデックスは常に 0 を返します。
//emlist[][ruby]{
p 255[-1] # => 0
//}
//emlist[複数ビットの例][ruby]{
0b01001101[2, 4] #=> 0b0011
0b01001100[2..5] #=> 0b0011
0b01001100[2...6] #=> 0b0011
# ^^^^
//}
self[nth]=bit... -
Integer
# [](nth , len) -> Integer (21141.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...lf[..j] で n & ((1 << (j + 1)) - 1) が 0 以外のとき
@raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき
//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010
a = 9**15
50.downto(0) {|n| print a[n] }
# => 000101110......01
//}
n[i] は (n >> i) & 1 と等価なので、負のインデックスは常に 0 を返します。
//emlist[][ruby]{
p 255[-1] # => 0
//}
//emlist[複数ビットの例][ruby]{
0b01001101[2, 4] #=> 0b0011
0b01001100[2..5] #=> 0b0011
0b01001100[2...6] #=> 0b0011
# ^^^^
//}
self[nth]=bit... -
Integer
# [](range) -> Integer (21141.0) -
nth 番目のビット(最下位ビット(LSB)が 0 番目)が立っている時 1 を、そうでなければ 0 を返します。
...lf[..j] で n & ((1 << (j + 1)) - 1) が 0 以外のとき
@raise ArgumentError self[...j] で n & ((1 << j) - 1) が 0 以外のとき
//emlist[][ruby]{
a = 0b11001100101010
30.downto(0) {|n| print a[n] }
# => 0000000000000000011001100101010
a = 9**15
50.downto(0) {|n| print a[n] }
# => 000101110......01
//}
n[i] は (n >> i) & 1 と等価なので、負のインデックスは常に 0 を返します。
//emlist[][ruby]{
p 255[-1] # => 0
//}
//emlist[複数ビットの例][ruby]{
0b01001101[2, 4] #=> 0b0011
0b01001100[2..5] #=> 0b0011
0b01001100[2...6] #=> 0b0011
# ^^^^
//}
self[nth]=bit... -
Integer
# gcd(n) -> Integer (21139.0) -
自身と整数 n の最大公約数を返します。
...//emlist[][ruby]{
2.gcd(2) # => 2
3.gcd(7) # => 1
3.gcd(-7) # => 1
((1<<31)-1).gcd((1<<61)-1) # => 1
//}
また、self や n が 0 だった場合は、0 ではない方の整数の絶対値を返します。
//emlist[][ruby]{
3.gcd(0)......# => 3
0.gcd(-7) # => 7
//}
@see Integer#lcm, Integer#gcdlcm... -
Integer
# lcm(n) -> Integer (21139.0) -
自身と整数 n の最小公倍数を返します。
...と発生します。
//emlist[][ruby]{
2.lcm(2) # => 2
3.lcm(-7) # => 21
((1<<31)-1).lcm((1<<61)-1) # => 4951760154835678088235319297
//}
また、self や n が 0 だった場合は、0 を返します。
//emlist[][ruby]{
3.lcm(0) # => 0......0.lcm(-7) # => 0
//}
@see Integer#gcd, Integer#gcdlcm... -
Integer
# pow(other , modulo) -> Integer (21133.0) -
算術演算子。冪(べき乗)を計算します。
...します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # =>......になりそうなとき、警告を出したうえで Float::INFINITY を返します。
//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}
判定の閾値は変わりえます。
@see BigDecimal#power......eError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
@raise ArgumentError 計算結果が巨大になりすぎる場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 **......> -3
5.pow(2, -8) # => -7
//}
計算結果が巨大すぎるときは ArgumentError が発生します。
//emlist[計算結果が巨大すぎる例][ruby]{
p 100**9999999999999999999
# => exponent is too large (ArgumentError)
//}
判定の閾値は変わりえます。
@see BigDecimal#power... -
Integer
# digits -> [Integer] (21128.0) -
base を基数として self を位取り記数法で表記した数値を配列で返します。 base を指定しない場合の基数は 10 です。
...い場合の基数は 10 です。
//emlist[][ruby]{
16.digits # => [6, 1]
16.digits(16) # => [0, 1]
//}
self は非負整数でなければいけません。非負整数でない場合は、Math::DomainErrorが発生します。
//emlist[][ruby]{
-10.digits # Math::DomainError: out of domai...