C++ — type of the division?

前端 未结 6 1445
陌清茗
陌清茗 2021-02-20 02:05

I want to make sure that my understanding of the return type of C++ division,

int / int => return is int?

float / float => return is which type? float?

d         


        
6条回答
  •  执笔经年
    2021-02-20 03:12

    Roughly speaking, in C++, in any scenario, both operands are converted to the "largest" type of the two operands' types before the operation is executed. See MSDN Standard Arithmetic Conversions.

提交回复
热议问题