+ 2

[solved] [C++] 0a100? What is this?

I was experimenting in C++ Sololearn Playground. I wanted to test if there is a specified syntax for numbers written in other number system (like in Python). And found this: https://code.sololearn.com/cFK6qJykmsjJ/?ref=app Could you, please, give links for information on this topic? (I thought that this question is not open-ended, but feel free to inform if it is open-ended)

8th Feb 2021, 11:30 AM
#0009e7 [get]
#0009e7 [get] - avatar
2 Answers
+ 6
get the `operator "" identifier` can be defined for literals to provide functionality for the syntax `<literal><identifier>` For example, https://code.sololearn.com/cJ5yqJmsz2Gn/?ref=app And that is why, the error message in your code says that `operator""a100` is not defined. Details about it here https://en.cppreference.com/w/cpp/language/user_literal
8th Feb 2021, 12:08 PM
XXX
XXX - avatar
+ 9
get , what you presented looks like a representation / literal for numbers (integers). but this literal containing an "a" is not valid. you can use like: 0b101 for binary numbers (base 2) 0o101 for octal numbers (base 8) 0x101 for hex numbers (base 16) i am not sure if you can define your own literals. you may find some more information here: https://en.cppreference.com/w/cpp/language/integer_literal
8th Feb 2021, 11:51 AM
Lothar
Lothar - avatar