FixedPointAsBoolArray 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.Numerics

Computes fixed-point approximation for a double and returns it as Bool array.

function FixedPointAsBoolArray (integerBits : Int, fractionalBits : Int, value : Double) : Bool[]

Input

integerBits : Int

Assumed number of integer bits (including the sign bit).

fractionalBits : Int

Assumed number of fractional bits.

value : Double

Value to be approximated.

Output : Bool[]

Example

Note that the first element in the Boolean array is the least-significant bit.

let bits = FixedPointAsBoolArray(2, 2,  1.25); // bits = [true, false, true, false]
let bits = FixedPointAsBoolArray(2, 2,  1.3);  // bits = [true, false, true, false], approximated
let bits = FixedPointAsBoolArray(2, 2, -1.75); // bits = [true, false, false, true], two's complement