Skip to content

Instantly share code, notes, and snippets.

@rpivo
Last active December 4, 2020 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpivo/138403dc1ccc7502558c28f2b26a47aa to your computer and use it in GitHub Desktop.
Save rpivo/138403dc1ccc7502558c28f2b26a47aa to your computer and use it in GitHub Desktop.
Binary, Hexadecimal, & Octal Numbers in JS

Binary, Hexadecimal, & Octal Numbers in JS

// these are safe to use in strict mode
'use strict'

/*
 binary
 preceded by 0b
 string sequence of 0s and 1s
 */
const binary22 = 0b10110 // 22

/*
 hexadecimal
 preceded by 0x
 string sequence of chars between 0-9,A-F
 */
const hexadecimal4602 = 0x11FA // 4602

/*
 octal
 preceded by 0o
 string sequence of chars between 0-7
 */
const octal5075 = 0o11723 // 5075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment