QuantumLibraries icon indicating copy to clipboard operation
QuantumLibraries copied to clipboard

Functions for smallest and largest representable fixed point

Open msoeken opened this issue 3 years ago • 2 comments
trafficstars

Functions for smallest and largest representable fixed point

Conceptual overview

This provides two functions to return the smallest and largest representable fixed point based on number of integer and fractional bits.

This should be added to the Numerics package.

Proposal

New and modified functions, operations, and UDTs

namespace Microsoft.Quantum.Math {

/// # Summary
/// Returns the smallest representable number for specific fixed point dimensions
///
/// # Input
/// ## integerBits
/// Number of integer bits
/// ## fractionalBits
/// Number of fractional bits
///
/// # Remark
/// The value can be computed as $-2^{p-1}$, where $p$ is the number of integer bits.
function SmallestFixedPoint(integerBits : Int, fractionalBits : Int) : Double { ... }

/// # Summary
/// Returns the largest representable number for specific fixed point dimensions
///
/// # Input
/// ## integerBits
/// Number of integer bits
/// ## fractionalBits
/// Number of fractional bits
///
/// # Remark
/// The value can be computed as $2^{p-1} - 2^{-q}$, where $p$
/// is the number of integer bits and $q$ is the number of fractional bits.
function LargestFixedPoint(integerBits : Int, fractionalBits : Int) : Double { ... }

}

Open questions

Which namespace fits well?

  • Microsoft.Quantum.Arithmetic
  • Microsoft.Quantum.Canon
  • Microsoft.Quantum.Math

msoeken avatar Jun 08 '22 08:06 msoeken

I would add formulas to API documentation clarifying what these values are - I think there is a nice enough formula for both. Other than that, looks good!

tcNickolas avatar Jul 05 '22 18:07 tcNickolas

Updated the issue.

msoeken avatar Jul 06 '22 10:07 msoeken