Kevin
Kevin

Reputation: 2050

In programming languages, what is typically the way used to represent binary values?

I'm not asking about a particular language, but just in general. I know that, for example, #0x or simply 0x is put before the number, or an h is placed after the number, to refer to hexadecimal.

Is there a similar "standard" for binary?

Upvotes: 0

Views: 140

Answers (2)

Barmar
Barmar

Reputation: 782673

Most of the popular languages don't have a way to enter binary literals. Common Lisp does it using #b prefix, and IIRC PL/I uses a b suffix. Those are the only ones I can think of off the top of my head that allow it.

I found a page at RosettaCode that describes how to enter integer literals in many different languages, including specifying radix.

Upvotes: 1

jkshah
jkshah

Reputation: 11713

b is used to represent binary numbers. Very few languages provides this support.

One best example is verilog / system verilog e.g. 4'b0101

Upvotes: 0

Related Questions