Module: BitInt::Native
- Defined in:
- lib/bitint/native.rb
Overview
BitInts that correspond to underlying C integer sizes.
Constant Summary collapse
- SCHAR =
A signed sizeof(char)-byte BitInt.
Technically C has a difference between
char, unsigned char, and signed char. But there’s no real easy way to tell from within ruby code. SoCHARdoesn’t exist. Base.create(bytes: Fiddle::SIZEOF_CHAR, signed: true)
- UCHAR =
An unsigned sizeof(char)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_CHAR, signed: false)
- SHORT =
A signed sizeof(short)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_SHORT, signed: true)
- USHORT =
An unsigned sizeof(short)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_SHORT, signed: false)
- INT =
A signed sizeof(int)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_INT, signed: true)
- UINT =
An unsigned sizeof(int)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_INT, signed: false)
- LONG =
A signed sizeof(long)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_LONG, signed: true)
- ULONG =
An unsigned sizeof(long)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_LONG, signed: false)
- LONG_LONG =
A signed sizeof(long long)-byte BitInt. Only enabled if the platform supports long long.
Base.create(bytes: Fiddle::SIZEOF_LONG_LONG, signed: true)
- ULONG_LONG =
An unsigned sizeof(long long)-byte BitInt. Only enabled if the platform supports long long.
Base.create(bytes: Fiddle::SIZEOF_LONG_LONG, signed: false)
- VOIDP =
An unsigned sizeof(void *)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_VOIDP, signed: false)
- SIZE_T =
An unsigned sizeof(size_t)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_SIZE_T, signed: false)
- SSIZE_T =
A signed sizeof(ssize_t)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_SSIZE_T, signed: true)
- PTRDIFF_T =
A signed sizeof(ptrdiff_t)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_PTRDIFF_T, signed: true)
- INTPTR_T =
A signed sizeof(intptr_t)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_INTPTR_T, signed: true)
- UINTPTR_T =
An unsigned sizeof(uintptr_t)-byte BitInt.
Base.create(bytes: Fiddle::SIZEOF_UINTPTR_T, signed: false)
Class Method Summary collapse
-
.big_endian? ⇒ Boolean
Returns
truewhen on a big endian system. -
.endianness ⇒ Object
(also: endian)
Helper method to fetch the endianness of the underlying system.
-
.little_endian? ⇒ Boolean
Returns
truewhen on a little endian system.
Class Method Details
.big_endian? ⇒ Boolean
Returns true when on a big endian system.
36 37 38 |
# File 'lib/bitint/native.rb', line 36 def big_endian? endianness == :big end |
.endianness ⇒ Object Also known as: endian
Helper method to fetch the endianness of the underlying system.
18 19 20 |
# File 'lib/bitint/native.rb', line 18 def endianness IS_LITTLE_ENDIAN ? :little : :big end |
.little_endian? ⇒ Boolean
Returns true when on a little endian system.
29 30 31 |
# File 'lib/bitint/native.rb', line 29 def little_endian? endianness == :little end |