Is there a division operation that produces both quotient and reminder?

前端 未结 4 1860
无人共我
无人共我 2021-01-12 03:00

Currently I write some ugly code like

    def div(dividend: Int, divisor: Int) = {
        val q = dividend / divisor
        val mod = dividend % divisor
          


        
4条回答
  •  不思量自难忘°
    2021-01-12 03:13

    BigInt does it

    def /%(that: BigInt): (BigInt, BigInt)
    

    Division and Remainder - returns tuple containing the result of divideToIntegralValue and the remainder.

提交回复
热议问题