File: logic.py

package info (click to toggle)
python-parsl 2025.01.13%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 12,072 kB
  • sloc: python: 23,817; makefile: 349; sh: 276; ansic: 45
file content (15 lines) | stat: -rw-r--r-- 400 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from typing import Tuple


def convert_to_binary(x: int) -> Tuple[bool, ...]:
    """Convert a nonnegative integer into a binary

    Args:
        x: Number to be converted
    Returns:
        The binary number represented as list of booleans
    """
    if x < 0:
        raise ValueError('`x` must be nonnegative')
    bin_as_string = bin(x)
    return tuple(i == '1' for i in bin_as_string[2:])