Libraries
Bin64 Source Code
 previous   up   next 

Types
bin64
Binary values with 64 bits.

bin64

const type: bin64

Binary values with 64 bits. This type supports bitwise operations but no integer arithmetic. The internal representation is the same as for integer.


Operator Summary
bin64
(attr bin64) . value
Default value of bin64 (bin64(0)).
integer
(attr integer) conv (in bin64: bits)
Convert to integer.
bin64
(attr bin64) conv (in integer: anInt)
Convert to bin64.
string
(in bin64: bits) radix (in integer: base)
Convert a bin64 value to a string using a radix.
string
(in bin64: bits) RADIX (in integer: base)
Convert a bin64 value to a string using a radix.
boolean
(in bin64: bits1) = (in bin64: bits2)
Check if two bin64 values are equal.
boolean
(in bin64: bits1) <> (in bin64: bits2)
Check if two bin64 values are not equal.
bin64
(in bin64: bits1) & (in bin64: bits2)
Compute a bitwise and of two bin64 values.
bin64
(in bin64: bits1) | (in bin64: bits2)
Compute a bitwise inclusive or of two bin64 values.
bin64
(in bin64: bits1) >< (in bin64: bits2)
Compute a bitwise exclusive or (xor) of two bin64 values.
bin64
~ (in bin64: bits)
Compute a bitwise not of a bin64 value.
bin64
(in bin64: bits) << (in integer: lshift)
Shift a bin64 value left by lshift bits.
bin64
(in bin64: bits) >> (in integer: lshift)
Shift a bin64 value right by rshift bits.
void
(inout bin64: bits) <<:= (in integer: lshift)
Shift a bin64 value left by lshift bits and assign the result back to bits.
void
(inout bin64: bits) >>:= (in integer: rshift)
Shift a bin64 value right by rshift bits and assign the result back to bits.
void
(inout bin64: bits1) &:= (in bin64: bits2)
Compute a bitwise and and assign the result back to bits1.
void
(inout bin64: bits1) |:= (in bin64: bits2)
Compute a bitwise inclusive or and assign the result back to bits1.
void
(inout bin64: bits1) ><:= (in bin64: bits2)
Compute a bitwise exclusive or (xor) and assign the result back to bits1.

Function Summary
bin64
bin64 (in integer: number)
Convert to bin64.
bin64
bin64 (in bigInteger: number)
Convert to bin64.
bin64
bin64 (in char: ch)
Convert to bin64.
bin64
bin64 (in float: number)
Get bits in IEEE 754 double-precision representation from a float.
integer
ord (in bin64: bits)
Convert to integer.
integer
integer (in bin64: bits)
Convert to integer.
bigInteger
big (in bin64: bits)
Convert to bigInteger.
bigInteger
bigInteger (in bin64: bits)
Convert to bigInteger.
float
float (in bin64: bits)
Get a float from bits in IEEE 754 double-precision representation.
integer
compare (in bin64: bits1, in bin64: bits2)
Compare two bin64 values.
integer
hashCode (in bin64: bits)
Compute the hash value of a bin64 value.
bin64
rand (attr bin64)
Compute pseudo-random bin64 value.
integer
bitLength (in bin64: bits)
Number of bits in the minimum binary representation.
integer
lowestSetBit (in bin64: bits)
Number of lowest-order zero bits in the binary representation.
string
str (in bin64: bits)
Convert an bin64 value to a string.
string
bytes (in bin64: bits, BE, in integer: length)
Convert a bin64 into a string of bytes with big-endian encoding.
string
bytes (in bin64: bits, LE, in integer: length)
Convert a bin64 into a string of bytes with little-endian encoding.
bin64
rotLeft (in bin64: x, in integer: shiftCount)
Rotate the bits of a bin64 value left by shiftCount bits.
bin64
rotRight (in bin64: x, in integer: shiftCount)
Rotate the bits of a bin64 value right by shiftCount bits.
bin64
getBinary (in bitset: set1, in integer: lowestBitNum)
Get 64 bits from a bitset starting with lowestBitNum.
bin64
float2MbfBits (in float: number, DOUBLE)
Get bits in MBF double-precision representation from a float.
float
mbfBits2Float (in bin64: bits)
Get a float from bits in MBF double-precision representation.
bin64
bin64 (in string: eightBytes, LE)
Convert a string of eight little-endian bytes to a bin64 value.
bin64
bin64 (in string: eightBytes, BE)
Convert a string of eight big-endian bytes to a bin64 value.

Operator Detail

. value

const bin64: (attr bin64) . value

Default value of bin64 (bin64(0)).


conv

const func integer: (attr integer) conv (in bin64: bits)

Convert to integer.

Returns:
the unchanged value as integer.

conv

const func bin64: (attr bin64) conv (in integer: anInt)

Convert to bin64.

Returns:
the unchanged value as bin64.

radix

const func string: (in bin64: bits) radix (in integer: base)

Convert a bin64 value to a string using a radix. The conversion uses the numeral system with the given base. Digit values from 10 upward are encoded with lower case letters. E.g.: 10 is encoded with a, 11 with b, etc.

bin64(48879) radix 16   returns "beef"
Returns:
the string result of the conversion.
Raises:
RANGE_ERROR - If base < 2 or base > 36 holds.
MEMORY_ERROR - Not enough memory to represent the result.

RADIX

const func string: (in bin64: bits) RADIX (in integer: base)

Convert a bin64 value to a string using a radix. The conversion uses the numeral system with the given base. Digit values from 10 upward are encoded with upper case letters. E.g.: 10 is encoded with A, 11 with B, etc.

bin64(48879) RADIX 16   returns "BEEF"
Returns:
the string result of the conversion.
Raises:
RANGE_ERROR - If base < 2 or base > 36 holds.
MEMORY_ERROR - Not enough memory to represent the result.

=

const func boolean: (in bin64: bits1) = (in bin64: bits2)

Check if two bin64 values are equal.

Returns:
TRUE if the two values are equal, FALSE otherwise.

<>

const func boolean: (in bin64: bits1) <> (in bin64: bits2)

Check if two bin64 values are not equal.

Returns:
FALSE if both values are equal, TRUE otherwise.

&

const func bin64: (in bin64: bits1) & (in bin64: bits2)

Compute a bitwise and of two bin64 values.

bin64(2#1100) & bin64(2#1010)  returns  bin64(2#1000)
Returns:
the bitwise and of the two values.

|

const func bin64: (in bin64: bits1) | (in bin64: bits2)

Compute a bitwise inclusive or of two bin64 values.

bin64(2#1100) | bin64(2#1010)  returns  bin64(2#1110)
Returns:
the bitwise inclusive or of the two values.

><

const func bin64: (in bin64: bits1) >< (in bin64: bits2)

Compute a bitwise exclusive or (xor) of two bin64 values.

bin64(2#1100) >< bin64(2#1010)  returns  bin64(2#0110)
Returns:
the bitwise xor of the two values.

~

const func bin64: ~ (in bin64: bits)

Compute a bitwise not of a bin64 value.

~bin64(2#1)  returns  bin64(16#fffffffffffffffe_)
Returns:
the bitwise not of the value.

<<

const func bin64: (in bin64: bits) << (in integer: lshift)

Shift a bin64 value left by lshift bits. Bits shifted beyond the highest bit position are lost.

bin64(16#1234567890abcde0) << 4  returns  bin64(16#234567890abcde00)
bin64(1) << 64                   raises OVERFLOW_ERROR
Returns:
the left shifted value.
Raises:
OVERFLOW_ERROR - If the shift amount is negative or greater equal 64.

>>

const func bin64: (in bin64: bits) >> (in integer: lshift)

Shift a bin64 value right by rshift bits. Bits shifted beyond the lowest bit position are lost.

bin64(16#1234567890abcde0) >> 4  returns  bin64(16#1234567890abcde)
Returns:
the right shifted value.
Raises:
OVERFLOW_ERROR - If the shift amount is negative or greater equal 64.

<<:=

const proc: (inout bin64: bits) <<:= (in integer: lshift)

Shift a bin64 value left by lshift bits and assign the result back to bits. Bits shifted beyond the highest bit position are lost.

Raises:
OVERFLOW_ERROR - If the shift amount is negative or greater equal 64.

>>:=

const proc: (inout bin64: bits) >>:= (in integer: rshift)

Shift a bin64 value right by rshift bits and assign the result back to bits. Bits shifted beyond the lowest bit position are lost.

Raises:
OVERFLOW_ERROR - If the shift amount is negative or greater equal 64.

&:=

const proc: (inout bin64: bits1) &:= (in bin64: bits2)

Compute a bitwise and and assign the result back to bits1.


|:=

const proc: (inout bin64: bits1) |:= (in bin64: bits2)

Compute a bitwise inclusive or and assign the result back to bits1.


><:=

const proc: (inout bin64: bits1) ><:= (in bin64: bits2)

Compute a bitwise exclusive or (xor) and assign the result back to bits1.


Function Detail

bin64

const func bin64: bin64 (in integer: number)

Convert to bin64.

Returns:
the unchanged value as bin64.

bin64

const func bin64: bin64 (in bigInteger: number)

Convert to bin64.

Returns:
the unchanged value as bin64.
Raises:
RANGE_ERROR - The number is negative or too big to fit into a bin64 value.

bin64

const func bin64: bin64 (in char: ch)

Convert to bin64.

Returns:
the unchanged value as bin64.

bin64

const func bin64: bin64 (in float: number)

Get bits in IEEE 754 double-precision representation from a float. IEEE 754 is a standard for floating point arithmetic. The double-precision format of IEEE 754 has a sign bit, an 11 bit exponent, and a 52 bit mantissa.

bin64(1.0)  returns  bin64(16#3ff0000000000000)
Parameters:
number - Float value to be converted to bin64.
Returns:
64 bits in IEEE 754 double-precision float representation.

ord

const func integer: ord (in bin64: bits)

Convert to integer.

Returns:
the unchanged value as integer.

integer

const func integer: integer (in bin64: bits)

Convert to integer.

Returns:
the unchanged value as integer.

big

const func bigInteger: big (in bin64: bits)

Convert to bigInteger.

Returns:
the unchanged value as integer.
Raises:
MEMORY_ERROR - Not enough memory to represent the result.

bigInteger

const func bigInteger: bigInteger (in bin64: bits)

Convert to bigInteger.

Returns:
the unchanged value as integer.
Raises:
MEMORY_ERROR - Not enough memory to represent the result.

float

const func float: float (in bin64: bits)

Get a float from bits in IEEE 754 double-precision representation. IEEE 754 is a standard for floating point arithmetic. The double-precision format of IEEE 754 has a sign bit, an 11 bit exponent, and a 52 bit mantissa.

float(bin64(16#3ff0000000000000))  returns  1.0
Parameters:
bits - Bits to be converted to a float.
Returns:
a float from bits in double-precision float representation.

compare

const func integer: compare (in bin64: bits1, in bin64: bits2)

Compare two bin64 values.

Returns:
-1, 0 or 1 if the first argument is considered to be respectively less than, equal to, or greater than the second.

hashCode

const func integer: hashCode (in bin64: bits)

Compute the hash value of a bin64 value.

Returns:
the hash value.

rand

const func bin64: rand (attr bin64)

Compute pseudo-random bin64 value. The random values are uniform distributed.

Returns:
a random bin64 value.

bitLength

const func integer: bitLength (in bin64: bits)

Number of bits in the minimum binary representation. Leading zero bits are not part of the minimum binary representation.

bitLength(bin64(0))  returns 0
bitLength(bin64(1))  returns 1
bitLength(bin64(4))  returns 3
Returns:
the number of bits.

lowestSetBit

const func integer: lowestSetBit (in bin64: bits)

Number of lowest-order zero bits in the binary representation. This is equal to the index of the lowest-order one bit (indices start with 0). If there are only zero bits (bits is bin64(0)) the result is -1.

lowestSetBit(bin64(0))  returns -1
lowestSetBit(bin64(1))  returns  0
lowestSetBit(bin64(4))  returns  2
Returns:
the number of lowest-order zero bits or -1 for lowestSetBit(bin64(0)).

str

const func string: str (in bin64: bits)

Convert an bin64 value to a string. The values is converted to a string with decimal representation. The conversion interprets the bin64 value as unsigned.

Returns:
the string result of the conversion.
Raises:
MEMORY_ERROR - Not enough memory to represent the result.

bytes

const func string: bytes (in bin64: bits, BE, in integer: length)

Convert a bin64 into a string of bytes with big-endian encoding. The result uses binary representation with a base of 256. The result contains chars (bytes) with an ordinal <= 255.

bytes(bin64(1413829460), BE, 5)  returns "\0;TEST"
bytes(bin64(1413829460), BE, 4)  returns "TEST"
bytes(bin64(1413829460), BE, 3)  raises RANGE_ERROR
Parameters:
bits - Bin64 to be converted.
length - Determines the length of the result string.
Returns:
a string of length bytes with the unsigned binary representation of bits.
Raises:
RANGE_ERROR - If length is negative or zero, or if the result would not fit in length bytes.
MEMORY_ERROR - Not enough memory to represent the result.

bytes

const func string: bytes (in bin64: bits, LE, in integer: length)

Convert a bin64 into a string of bytes with little-endian encoding. The result uses binary representation with a base of 256. The result contains chars (bytes) with an ordinal <= 255.

bytes(bin64(1413829460), LE, 5)  returns "TEST\0;"
bytes(bin64(1413829460), LE, 4)  returns "TEST"
bytes(bin64(1413829460), LE, 3)  raises RANGE_ERROR
Parameters:
bits - Bin64 to be converted.
length - Determines the length of the result string.
Returns:
a string of length bytes with the unsigned binary representation of bits.
Raises:
RANGE_ERROR - If length is negative or zero, or if the result would not fit in length bytes.
MEMORY_ERROR - Not enough memory to represent the result.

rotLeft

const func bin64: rotLeft (in bin64: x, in integer: shiftCount)

Rotate the bits of a bin64 value left by shiftCount bits. The vacant bit positions at the right side are filled in with the bits that are shifted out at the left side.

rotLeft(bin64(16#76543210fedcba98), 12)  returns  bin64(16#43210fedcba98765)
Returns:
the left rotated value.
Raises:
OVERFLOW_ERROR - If the shift amount is negative or greater than 64.

rotRight

const func bin64: rotRight (in bin64: x, in integer: shiftCount)

Rotate the bits of a bin64 value right by shiftCount bits. The vacant bit positions at the left side are filled in with the bits that are shifted out at the right side.

rotRight(bin64(16#76543210fedcba98), 40)  returns  bin64(16#10fedcba98765432)
Returns:
the right rotated value.
Raises:
OVERFLOW_ERROR - If the shift amount is negative or greater than 64.

getBinary

const func bin64: getBinary (in bitset: set1, in integer: lowestBitNum)

Get 64 bits from a bitset starting with lowestBitNum.

Returns:
a bit pattern with 64 bits from set1.

float2MbfBits

const func bin64: float2MbfBits (in float: number, DOUBLE)

Get bits in MBF double-precision representation from a float. Microsoft Binary Format (MBF) is a format for floating point numbers. The double-precision version of MBF has a 8 bit exponent, a sign bit and a 55 bit mantissa.

float2MbfBits(1.0, DOUBLE)  returns  bin64(16#8100000000000000_)
Parameters:
number - Float value to be converted to bin64.
Returns:
64 bits in MBF double-precision float representation.
Raises:
RANGE_ERROR - If number is not representable in MBF. NaN, Infinity and -Infinity are not representable in MBF. Numbers with an absolute value larger than 1.7014118346046921e+38 are also not representable in MBF.

mbfBits2Float

const func float: mbfBits2Float (in bin64: bits)

Get a float from bits in MBF double-precision representation. Microsoft Binary Format (MBF) is a format for floating point numbers. The double-precision version of MBF has a 8 bit exponent, a sign bit and a 55 bit mantissa.

mbfBits2Float(bin64(16#8100000000000000_))  returns  1.0
Parameters:
bits - Bits to be converted to a float.
Returns:
a float from bits in double-precision float representation.

bin64

const func bin64: bin64 (in string: eightBytes, LE)

Convert a string of eight little-endian bytes to a bin64 value.

Returns:
the bin64 value.

bin64

const func bin64: bin64 (in string: eightBytes, BE)

Convert a string of eight big-endian bytes to a bin64 value.

Returns:
the bin64 value.


 previous   up   next