Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有任何内置函数来获得除法的商。Math.DivRem似乎不适用。
Math.DivRem
整数操作数的除法将产生整数商。如果您的输入是浮点类型,只需先将它们转换为整数类型:
double num1 = 27; int num2 = 7; double dblResult = num1 / num2; // will yield floating point result 3.857... int intResult =(int)num1 / num2; // will yield integer quotient 3