Skip to content

U8 (Unsigned 8-bit Integer)

The U8 type represents an unsigned 8-bit integer in raypy. It can store values from 0 to 255.

  • U8 can only store values from 0 to 255 (inclusive)
  • Negative and greater than 255 values will raise a ValueError

Type Information

Type Rayforce Object Type Code Range
U8 -2 0-255

Creating U8 Values

>>> from raypy import types as t

>>> t.U8(0)
U8(0)

>>> t.U8(255)
U8(255)

Accessing Values

>>> u = U8(100)
>>> u
U8(100)

>>> u.value
100

Binary and Hexadecimal

# Working with different number bases
>>> t.U8(0b11111111)  # Binary
U8(255)

>>> t.U8(0o377)  # Octal
U8(255)

>>> t.U8(0xFF)  # Hexadecimal
U8(255)

Comparison

>>> byte1 = U8(100)
>>> byte2 = U8(100)
>>> byte3 = U8(200)

>>> byte1 == byte2
True

>>> byte1 == byte3
False