C++ Best way to get integer division and remainder

后端 未结 8 1952
挽巷
挽巷 2020-12-01 00:29

I am just wondering, if I want to divide a by b, and am interested both in the result c and the remainder (e.g. say I have number of seconds and want to split that into minu

8条回答
  •  囚心锁ツ
    2020-12-01 01:08

    In addition to the aforementioned std::div family of functions, there is also the std::remquo family of functions, return the rem-ainder and getting the quo-tient via a passed-in pointer.

    [Edit:] It looks like std::remquo doesn't really return the quotient after all.

提交回复
热议问题