This language bar is your friend. Select your favorite languages!
Edit summary for version 22 :

Version 21

Version 22

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Code
var Iter,n:integer;
[...]
 S := '';
  for Iter := 0 to n do
    if (x shr Iter) and 1 = 0 then
      S := '0' + S
    else
      S := '1' + S;   
Code
var Iter,n:integer;
[...]
  S := '';
  for Iter := 0 to n do
    s:= Char(Ord('0')+(x shr Iter) and 1) + S;   
Comments bubble
n: Number of digits