Logo

Programming-Idioms

History of Idiom 76 > diff from v74 to v75

Edit summary for version 75 by programming-idioms.org:
[JS] Variable names x, s. +DemoURL. +DocURL.

Version 74

2020-11-25, 22:11:58

Version 75

2020-11-25, 22:15:49

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
var base10number = 123

var base2number = base10number.toString(2)
Code
let s = x.toString(2);
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString
Demo URL
https://repl.it/@ProgIdioms/WrithingPeriodicModulus