abstract struct Int
- Int
 - Number
 - Value
 - Object
 
Overview
Int is the base type of all integer types.
There are four signed integer types: Int8, Int16, Int32 and Int64,
being able to represent numbers of 8, 16, 32 and 64 bits respectively.
There are four unsigned integer types: UInt8, UInt16, UInt32 and UInt64.
An integer literal is an optional + or - sign, followed by
a sequence of digits and underscores, optionally followed by a suffix.
If no suffix is present, the literal's type is the lowest between Int32, Int64 and UInt64
in which the number fits:
1 # Int32
1_i8  # Int8
1_i16 # Int16
1_i32 # Int32
1_i64 # Int64
1_u8  # UInt8
1_u16 # UInt16
1_u32 # UInt32
1_u64 # UInt64
+10 # Int32
-20 # Int32
2147483648          # Int64
9223372036854775808 # UInt64
The underscore _ before the suffix is optional.
Underscores can be used to make some numbers more readable:
1_000_000 # better than 1000000
Binary numbers start with 0b:
0b1101 # == 13
Octal numbers start with 0o:
0o123 # == 83
Hexadecimal numbers start with 0x:
0xFE012D # == 16646445
0xfe012d # == 16646445
  Included Modules
Defined in:
int/each_combination.crint/each_subset.cr
atcoder/src/Prime.cr
math/mint.cr
math/powmod.cr
math/prime_factor.cr
Class Method Summary
- 
        .each_combination(n : Int, k : Int)
        
          
Returns an iterator that returns all integers whose bit_length is n and popcount is k.
 - 
        .each_combination(n : Int, k : Int, &) : Nil
        
          
Calls the given block for each integer whose bit_length is n and popcount is k.
 
Instance Method Summary
- #divisors : Array(self)
 - #each_divisor(&) : Nil
 - 
        #each_subset
        
          
Returns an iterator that returns all subsets of
self. - 
        #each_subset(&)
        
          
Calls the given block for each subset of
self. - 
        #powmod(exp : Int, mod : self)
        
          
Caluclates
self ** exp % mod. - #prime_factor : Array(Tuple(self, Int32))
 - #to_m(type : M.class) forall M
 
Instance methods inherited from module Comparable(BigDecimal)
  
  
    
      max(x : T)
    max, 
    
  
    
      min(x : T)
    min
    
  
    
    
  
    
  Instance methods inherited from module Comparable(BigRational)
  
  
    
      max(x : T)
    max, 
    
  
    
      min(x : T)
    min
    
  
    
    
  
    
  Instance methods inherited from module Comparable(BigInt)
  
  
    
      max(x : T)
    max, 
    
  
    
      min(x : T)
    min
    
  
    
    
  
    
    
    
  
    
  Instance methods inherited from module Comparable(BigFloat)
  
  
    
      max(x : T)
    max, 
    
  
    
      min(x : T)
    min
    
  
    
    
  
    
  Instance methods inherited from module Comparable(Number)
  
  
    
      max(x : T)
    max, 
    
  
    
      min(x : T)
    min
    
  
    
    
  
    
    
    
  
    
    
    
  
Class Method Detail
Returns an iterator that returns all integers whose bit_length is n and popcount is k.
Int.each_combination(3, 2).to_a # => [0b011, 0b101, 0b110]
        Calls the given block for each integer whose bit_length is n and popcount is k.
# x = 0b011, 0b101, 0b110
Int.each_combination(3, 2) { |x| }
        Instance Method Detail
Returns an iterator that returns all subsets of self.
0b101.each_subset.to_a # => [0b101, 0b100, 0b001, 0b000]
        Calls the given block for each subset of self.
# x = 0b101, 0b100, 0b001, 0b000
0b101.each_subset { |x| }