to_csdnnz_i

Function to_csdnnz_i 

Source
pub fn to_csdnnz_i(decimal_value: i32, nnz: u32) -> String
Expand description

Convert to CSD (Canonical Signed Digit) String representation

The to_csdnnz_i function converts an integer into a Canonical Signed Digit (CSD) representation approximately with a specified number of non-zero digits. This is the integer version of to_csdnnz.

Arguments:

  • decimal_value: The decimal_value parameter is an integer that represents the number for which we want to generate the CSD (Canonical Signed Digit) representation.
  • nnz: The parameter nnz stands for “number of non-zero bits”. It represents the maximum number of non-zero bits allowed in the output CSD (Canonical Signed Digit) representation of the given decimal_value.

Returns:

The function to_csdnnz_i returns a string representation of the given integer in Canonical Signed Digit (CSD) format.

§Examples

use csd::csd::to_csdnnz_i;

assert_eq!(to_csdnnz_i(28, 4), "+00-00".to_string());
assert_eq!(to_csdnnz_i(-0, 4), "0".to_string());
assert_eq!(to_csdnnz_i(0, 4), "0".to_string());
assert_eq!(to_csdnnz_i(158, 2), "+0+00000".to_string());