Why are complex numbers in Python denoted with 'j' instead of 'i'?

后端 未结 5 2253
-上瘾入骨i
-上瘾入骨i 2020-12-05 03:55

I know this is an electrical engineering convention, but I\'m still wondering why it was chosen for Python. I don\'t know other programming languages with complex-number lit

5条回答
  •  半阙折子戏
    2020-12-05 04:43

    To answer "does anyone know any [other programming languages with complex-number literals] that do use i?"

    Yes, C++ since the C++14 standard. You have to use the right namespace though:

    #include 
    using namespace std::complex_literals;
    
    std::complex z = 2 + 3i;
    

提交回复
热议问题