Skip to content

IntToBinary

IntToBinary

Description

Convert an integer to a binary string.

Parameters

Name Direction Description
value in Integer to convert

Usage example (from documentation)

  Str bits = IntToBinary(&value);

Returns

Base-2 representation without a prefix.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    Str IntToBinary(Int *value) {
        return IntToStrRadix(value, 2, false);
    }
    
        Int value = IntFrom(13);
        Str text  = IntToBinary(&value);
    
        bool result = IntBitLength(&value) == 4;
    
        Int value = IntFromBinary("001011");
        Str text  = IntToBinary(&value);
    
        bool result = IntToU64(&value) == 11;
    
        Int zero = IntFromBinary("0");
        Str text = IntToBinary(&zero);
    
        bool result = IntBitLength(&zero) == 0;
        z = "10100011";
        StrReadFmt(z, "{b}", bin);
        bin_text = IntToBinary(&bin);
        success  = success && (ZstrCompare(bin_text.data, "10100011") == 0);
    
        IntAdd(&result_value, &a, &b);
        text = IntToBinary(&result_value);
    
        bool result = IntToU64(&result_value) == 256;
Last updated on