Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the integer suffix J mean?

I have the following source:

int main() { 000J; } 

With gcc 4.8.4 it compiles without errors. I know there are suffixes like L or U, but I didn't find anything about J.

So what does it do?

like image 355
happyMOOyear Avatar asked Nov 05 '15 16:11

happyMOOyear


People also ask

What is prefix and suffix in C++?

Prefixes − Prefixes denotes the base of the value. For example, 0x10 indicates hexadecimal value with 0x. Suffixes − Suffixes denotes the type of the value. For example, 8465484156155LL denotes a long long integer.

What is L at the end of number in C++?

L tells the compiler that the number is of type Long. Long is a signed type greater than or equal to an int in size. On most modern compilers, this means that the number will take 4 bytes of memory.


Video Answer


2 Answers

I get a warning:

Imaginary constants are a GNU extension

The J suffix is a GNU extension, which causes the literal to be of a _Complex type.

More info here: https://gcc.gnu.org/onlinedocs/gcc/Complex.html

like image 57
emlai Avatar answered Sep 26 '22 08:09

emlai


As zenith mentioned, this is a GNU extension for writing imaginary literals. I really want to comment on the rationale of using j for this purpose as imallett is wondering but I don't have enough reputation to comment on zenith's answer. I'll leave this as an answer anyway as it might be helpful to others.

As this link explains, both i and j can be used to write imaginary literals using this GNU extension. The reason why i is used for this is obvious, but the reason why j is used as well is that j is commonly used to denote the imaginary unit in electrical engineering and control systems engineering to prevent confusion as i is already used to denote electrical current in those contexts.

like image 35
Jordan Melo Avatar answered Sep 22 '22 08:09

Jordan Melo