あなたがしたいことに応じて(ベース10で、私は仮定します)、これを行うことができます:
int64_t radix = 1000000; // or some other power of 10
x -= x%radix; // last 6 decimal digits are now 0
// e.g: from 3453646345345345 to 3453646345000000
またはこれ(前の回答のように):
x /= radix; // last 6 decimal digits are gone, the result rounded down
// e.g: from 3453646345345345 to 3453646345
編集への応答
radix
目的に応じて、モジュラスの例を 30000 に変更できます。
int64_t timeInterval = 30000;
displayTime = actualTime - (actualTime % timeInterval);
displayTime
とactualTime
はミリ秒単位です。displayTime
この場合、単位はミリ秒のままですが、(切り捨てられた) 粒度は 30 秒になります。
粒度を切り上げるには、次の操作を実行できます。
int64_t timeInterval = 30000;
int64_t modulus = actualTime % timeInterval;
displayTime = actualTime - modulus + (modulus?timeInterval:0);
ただし、あなたが求めていることに基づいて、表示値を数ティックごとに更新したいだけのようです。以下も同様に機能します。
if((actualTime - displayTime) >= timeInterval){
displayTime = actualTime - (actualTime % timeInterval);
}
C の整数型を許してください。使用している整数の幅について明確にすることを好みます:P.