C++11 - any built-in support for binary literals?

Feb 1, 2013 at 1:44am
I've done some googling and as far as I can tell, I would have to write my own literal suffix operator to achieve a binary literal. I just wanted to check to be sure there isn't already one in the standard C++11 libraries (not another library like boost).
Feb 1, 2013 at 4:25am
What do you mean by binary literal?
Feb 1, 2013 at 4:32am
No, C++ has no binary literals.
Feb 1, 2013 at 4:57am
@vlad OK, thanks.

@naraku in Java 7, for example:
int TheNumberSeventeen = 0b10001;
Even in Google if you type "17 to binary" it uses that notation.
Last edited on Feb 1, 2013 at 4:58am
Feb 1, 2013 at 7:01am
In C++, it would have to be a suffix notation; something like 111010_b or 10111_B
http://liveworkspace.org/code/2VqOZt$0

The plus point (always a plus point in C++) is that the idea of literals is extensible; we can have literals for user defined types as well.
Topic archived. No new replies allowed.