What is numeric promotion?

前端 未结 4 412
抹茶落季
抹茶落季 2020-12-11 15:48

Can any one tell what is numeric promotion?

4条回答
  •  半阙折子戏
    2020-12-11 16:25

    If you look here, you will see the following quote:

    Numeric promotion (§5.6) brings the operands of a numeric operator to a common type so that an operation can be performed.

    They are referencing this section, where they give a variety of examples. The classic example is that of an int times a float. The integer is promoted to a float so that the multiplied result is, therefore, a float.

提交回复
热议问题