Module: BitInt
- Defined in:
- lib/bitint/base.rb,
lib/bitint.rb,
lib/bitint/bitint.rb,
lib/bitint/native.rb,
lib/bitint/version.rb,
lib/bitint/constants.rb,
lib/bitint/refinements.rb,
lib/bitint/overflow_error.rb
Overview
rbs_inline: enabled
Defined Under Namespace
Modules: Native, Refinements Classes: Base, OverflowError
Constant Summary collapse
- VERSION =
The current version of BitInt.
'0.7.0'- U8 =
An unsigned 8-bit integer
U(8)
- U16 =
An unsigned 16-bit integer
U(16)
- U32 =
An unsigned 32-bit integer
U(32)
- U64 =
An unsigned 64-bit integer
U(64)
- U128 =
An unsigned 128-bit integer
U(128)
- I8 =
A signed 8-bit integer
I(8)
- I16 =
A signed 16-bit integer
I(16)
- I32 =
A signed 32-bit integer
I(32)
- I64 =
A signed 64-bit integer
I(64)
- I128 =
A signed 128-bit integer
I(128)
Class Method Summary collapse
-
.[](bits, signed: false) ⇒ subclass of Base
Helper to create new Base classes.
-
.I(bits) ⇒ subclass of Base
(also: signed, S)
Helper to create new signed Base classes.
-
.U(bits) ⇒ subclass of Base
(also: unsigned)
Helper to create new unsigned Base classes.
Class Method Details
.[](bits, signed: false) ⇒ subclass of Base
Helper to create new Base classes.
This method just wraps BitInt::Base.create.
Example
puts BitInt[9]::MAX #=> 511
puts BitInt[9, signed: false]::MAX #=> 511
puts BitInt[9, signed: true]::MAX #=> 255
50 |
# File 'lib/bitint/bitint.rb', line 50 def [](bits, signed: false) = Base.create(bits: bits, signed: signed) |
.I(bits) ⇒ subclass of Base Also known as: signed, S
Helper to create new signed Base classes.
This method just wraps BitInt::Base.create
Example
puts BitInt::I(16)::MAX #=> 32767
32 |
# File 'lib/bitint/bitint.rb', line 32 def I(bits) = Base.create(bits: bits, signed: true) |
.U(bits) ⇒ subclass of Base Also known as: unsigned
Helper to create new unsigned Base classes.
This method just wraps BitInt::Base.create
Example
puts BitInt::U(16)::MAX #=> 65535
18 |
# File 'lib/bitint/bitint.rb', line 18 def U(bits) = Base.create(bits: bits, signed: false) |