1

I am using Apple LLVM version 7.3.0 (clang-703.0.31) to compile some code and I find that 1j could be a constant value.

In the following code snippet, I assign int b with value 1j and it compiles.

But j is not any variable I have defined.

Can anybody explain what is 1j? Or it is a compiler bug?

Thanks a lot.

#include <iostream>

using namespace std;

int main() {
    // What is 1j? Why this code can compile??
    int b = 1j;
    cout << b << endl;
    return 0;
}

I have seen another post explaining this is complex number.

What does the integer suffix J mean?

And using compiler option -pedantic would raise a warning for it.

Community
  • 1
  • 1
user791961
  • 57
  • 7

1 Answers1

0

The suffix i and j is used for complex numbers.

Soren
  • 14,402
  • 4
  • 41
  • 67