BoolArrayAsBigInt function
Warning
This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.
Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.
Namespace: Microsoft.Quantum.Convert
Package: Microsoft.Quantum.QSharp.Foundation
Converts a given array of Booleans to an equivalent big integer. The 0 element of the array is the least significant bit of the big integer.
function BoolArrayAsBigInt (a : Bool[]) : BigInt
Input
a : Bool[]
Output : BigInt
Example
let bi1 = BoolArrayAsBigInt([true, false, true]); // Padded to 10100000 -> 5
let bi2 = BoolArrayAsBigInt([false, false, false, false, false, false, false, true]); // Not padded -> -128
Remarks
Note that the Boolean array is padded on the right with false
values to a length that is a multiple of 8,
and then treated as a little-endian notation of a positive or negative number following two's complement semantics.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for