PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Binary Literals

Binary Literals

Binary Literals are a language feature.

A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method of mathematical expression which uses only two symbols: typically "0" (zero) and "1" (one).

Languages with Binary Literals include Java, JavaScript, Python, Perl, Swift, MySQL, Haskell, Prolog, Julia, Elixir, OCaml, F#, D, Chapel, Verilog, Eiffel, Reason, VHDL, Zig, Opa, Ceylon, F*, Coq, K, SystemVerilog, Monkey, Isabelle, AspectJ, Futhark, Felix, ooc, BlitzBasic, Whiley, MiniD, BlitzMax, Logtalk, parasail, Earl Grey, FloScript, nimrod, CBOR data definition language, Savi, Croc

Example from Java, AspectJ:

// 0[bB][01][01_]*[lL]?

Example from JavaScript:

// 0[bB][01]+n?

Example from Python:

# 0[bB](?:_?[01])+

Example from Perl:

# 0b[01]+(_[01]+)*

Example from Swift:

// 0b[01_]+

Example from MySQL:

-- b'[01]+'

Example from Haskell:

-- 0[bB]_*[01](_*[01])*

Example from Prolog:

% 0b[01]+

Example from Julia:

# 0b[01]+((_[01]+)+)?

Example from Elixir:

# 0b[01]+

Example from F#:

// 0[bB][01][01_]*[uU]?[yslLn]?

Example from D:

// 0[Bb][01_]+

Example from Chapel:

// 0[bB][01]+

Example from Verilog:

// ([0-9]+)|(\'b)[01]+

Example from Eiffel:

-- 0[bB][01]+

Example from Reason, MiniD:

// 0[bB][01][01_]*

Example from VHDL:

-- B"[01_]+"

Example from Ceylon:

// \$([01]{4})(_[01]{4})+

Example from K:

/ [01]+b

Example from SystemVerilog:

// ([1-9][_0-9]*)?\s*\'[sS]?[bB]\s*[xXzZ?01][_xXzZ?01]*

Example from Monkey:

' \%[10]+

Example from Felix:

// 0[Bb][01_]+([tTsSiIlLvV]|ll|LL|([iIuU])(8|16|32|64))?

Example from Whiley:

// [01]+b

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub