从另一个号码获取一个不太具体的号码

Blu*_*ell 2 java math numbers bit-manipulation

对,抱歉我想不出谷歌这个正确的话.所以我不得不问.

我有一个long(System.currentTimeMillis())

让我们说

3453646345345345

我想删除最后六位(或其他数字)的数字,我想我可以这样做一些位移?

所以我最终会

3453646345

编辑

我想System.currentTimeMillis()在一个时间框内得到,所以如果我要求时间然后在29秒后再次询问它将返回相同的数字,但如果我问31秒后它将返回不同的数字.30秒的时间盒可配置.

Ada*_*der 6

你必须简单地除以1M long shorter = System.currentTimeMillis() / 1000000L;

  • 因此,使用`int numbersToRemove`参数放入一个方法,并使用`System.currentTimeMillis()/(long)Math.pow(10,numbersToRemove)`. (3认同)