Будет ли JVM оптимизировать эту математическую операцию?JAVA

Программисты JAVA общаются здесь
Гость
Будет ли JVM оптимизировать эту математическую операцию?

Сообщение Гость »

Код: Выделить всё

long time= (getTime()/60000L) * 60000L

The

Код: Выделить всё

getTime()
will return unix time in millis. I am exploiting division with longs to write off seconds and millis. The result must also be in unix time format (resolution upto millis)

I am wondering if JVM would optimise the above code to

Код: Выделить всё

long time= getTime()

But this will alter the result.

Or is there a better, cleaner way? (Can't change getTime's return type, which is also long)

Thanks in advance for any help.


Источник: https://stackoverflow.com/questions/781 ... -operation

Вернуться в «JAVA»