Share via


Integer.ToBinaryString(Int32) Method

Definition

Returns a string representation of the integer argument as an unsigned integer in base 2.

[Android.Runtime.Register("toBinaryString", "(I)Ljava/lang/String;", "")]
public static string ToBinaryString (int i);
[<Android.Runtime.Register("toBinaryString", "(I)Ljava/lang/String;", "")>]
static member ToBinaryString : int -> string

Parameters

i
Int32

an integer to be converted to a string.

Returns

the string representation of the unsigned integer value represented by the argument in binary (base&nbsp;2).

Attributes

Remarks

Returns a string representation of the integer argument as an unsigned integer in base&nbsp;2.

The unsigned integer value is the argument plus 2<sup>32</sup> if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in binary (base&nbsp;2) with no extra leading 0s.

The value of the argument can be recovered from the returned string s by calling Integer#parseUnsignedInt(String, int) Integer.parseUnsignedInt(s, 2).

If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u005Cu0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The characters '0' ('\u005Cu0030') and '1' ('\u005Cu0031') are used as binary digits.

Added in 1.0.2.

Java documentation for java.lang.Integer.toBinaryString(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to