HomeManualTopicsTypesSymbols

std::bin

converts a positive integer value into a string consisting of binary digits

Parameters

val
the value to convert
size (default: undefined)
the optional minimum length

Result

string
a string consisting of binary digits

Description

The optional second parameter specifies the minimum length of the resulting string. If there are fewer binary digits than the specified length, the strint is left-padded with zeros.

Example

println! bin(123)

Output

1111011

Example

println! bin(123 8)

Output

01111011

Topics

Math

Strings

See also

std::hex converts a positive integer value into a string consisting of hexadecimal digits
std::oct converts a positive integer value into a string consisting of octal digits
std::to_string returns a human readable presentation of the object