Logo

Programming-Idioms

History of Idiom 76 > diff from v68 to v69

Edit summary for version 69 by programming-idioms.org:
New C# implementation by user [programming-idioms.org]

Version 68

2020-11-25, 22:00:04

Version 69

2020-11-25, 22:02:10

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"

Variables
s,x
Variables
s,x
Extra Keywords
int radix
Extra Keywords
int radix
Code
String s = Convert.ToString(x,2).PadLeft(16, '0');
Comments bubble
If you want some leading zeroes.
Demo URL
https://repl.it/@ProgIdioms/StrangeVastCharacterencoding-1