Exponential Operator in C++

后端 未结 5 779
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 09:46

I am taking a class in C++ and I noticed there are only a few math operators to use. I also noticed that C++ does not come with an exponential operator within its math libr

5条回答
  •  广开言路
    2020-12-06 10:09

    According to Bjarne Stroustrup in his book The design and evolution of C++. They decided to avoid exponential operator because :

    • An operator provides notational convenience, but does not provide any new functionality. Members of the working group, representing heavy users of scientific/engineering computation, indicated that the operator syntax provides minor syntactic convenience.
    • Every user of C++ must learn this new feature
    • Users have stressed the importance of susbtituting their own specialized exponentiation functions for the system default, which would not be possible with an intrinsic operator
    • The proposal is not sufficiently well motivated. In particular, by looking at one 30000 line Fortran program one cannot conclude that the operator would be widely used in C++
    • The proposal requires adding a new operator and adding another precedence level thus increasing the complexity of the language

提交回复
热议问题