mirror of
https://github.com/erg-lang/erg.git
synced 2025-07-16 01:25:24 +00:00
63 lines
1.5 KiB
Python
63 lines
1.5 KiB
Python
.Int: ClassType
|
|
.Int.
|
|
Real: Float
|
|
Imag: Float
|
|
Denominator: Nat
|
|
Numerator: Int
|
|
'''erg
|
|
assert 1.abs() == 1
|
|
assert -1.abs() == 1
|
|
'''
|
|
abs: (self: .Int) -> Nat
|
|
as_integer_ratio: (self: .Int) -> (Int, Int)
|
|
'''
|
|
Number of ones in the binary representation of the absolute value of self.
|
|
|
|
Also known as the population count.
|
|
'''
|
|
'''japanese
|
|
2進数表現の絶対値の中の1の数。
|
|
|
|
ハミング重みとも呼ばれる。
|
|
'''
|
|
'''erg
|
|
assert bin(13) == "0b1101"
|
|
assert 13.bit_count() == 3
|
|
'''
|
|
'''python
|
|
assert bin(13) == "0b1101"
|
|
assert (13).bit_count() == 3
|
|
'''
|
|
bit_count: (self: .Int) -> Nat
|
|
'''
|
|
Number of bits necessary to represent self in binary.
|
|
'''
|
|
'''japanese
|
|
2進数表現においてselfを表すのに必要なビット数。
|
|
'''
|
|
'''erg
|
|
assert bin(37) == "0b100101"
|
|
assert 37.bit_length() == 6
|
|
'''
|
|
'''python
|
|
assert bin(37) == "0b100101"
|
|
assert (37).bit_length() == 6
|
|
'''
|
|
bit_length: (self: .Int) -> Nat
|
|
conjugate: (self: .Int) -> .Int
|
|
from_bytes: (bytes: Bytes, byteorder := {"big", "little"}, signed := Bool) -> .Int
|
|
'''
|
|
Predecessor of `self` (`self -1`).
|
|
'''
|
|
'''erg
|
|
assert 1.pred() == 0
|
|
'''
|
|
pred: (self: .Int) -> .Int
|
|
'''
|
|
Successor of `self` (`self + 1`).
|
|
'''
|
|
'''erg
|
|
assert 1.succ() == 2
|
|
'''
|
|
succ: (self: .Int) -> .Int
|
|
to_bytes: (self: .Int, length := Nat, byteorder := {"big", "little"}, signed := Bool) -> Bytes
|