cirq.big_endian_int_to_digits
Separates an integer into big-endian digits.
cirq.big_endian_int_to_digits(
val: int,
*,
digit_count: Optional[int] = None,
base: Union[int, Iterable[int]]
) -> List[int]
Args |
val
|
The integer to get digits from. Must be non-negative and less than
the maximum representable value, given the specified base(s) and
digit count.
|
base
|
The base, or list of per-digit bases, to separate val into. When
a list of bases is specified, the last entry in the list is the
base for the last entry of the result (i.e. the least significant
digit). That is to say, the bases are also specified in big endian
order.
|
digit_count
|
The length of the desired result.
|
Returns |
The list of digits.
|
Raises |
ValueError
|
Unknown digit count. The base was specified as an integer and a
digit_count was not provided.
Inconsistent digit count. The base was specified as a per-digit
list, and digit_count was also provided, but they disagree.
|
Examples |
>>> cirq.big_endian_int_to_digits(11, digit_count=4, base=10)
[0, 0, 1, 1]
cirq.big_endian_int_to_digits(11, base=[2, 3, 4])
[0, 2, 3]
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-27 UTC."],[],[]]