Utilities

class oberon.util.binary_addressing_mixin[source]

Permit integers to be addressed bit-wise.

Single indexing (foo[bar]) returns a Boolean value, while slicing returns an integer (foo[bar:baz]). Slice indexes are left-to-right and do not support step parameter.

oberon.util.bint

alias of oberon.util.blong

class oberon.util.blong[source]
oberon.util.python_int_to_signed_int(i, width=32)[source]

Given a Python integer, possibly negative, return the Python integer that has the same bit pattern as the C signed int of the same value would have.

I.e.:
>>> n = -23
>>> bin(n)
'-0b10111'
>>> n = python_int_to_signed_int(n)
>>> bin(n)
'0b11111111111111111111111111101001'
>>> 
oberon.util.signed_int_to_python_int(i, width=32)[source]

Convert a Python integer representing the bit-pattern of a C signed int into a Python integer of the same value.

I.e.:
>>> n = 0b11111111111111111111111111101001
>>> n
4294967273
>>> n = 4294967273
>>> bin(n)
'0b11111111111111111111111111101001'
>>> n = signed_int_to_python_int(n)
>>> n
-23