Are arithmetic operations on literals calculated at compile time or run time?

前端 未结 3 1861
挽巷
挽巷 2020-12-06 09:14

I have the following:

double timeInMinutes = (double) timeInMilliseconds / (1000 * 60);

Is the operation (1000 * 60) done at c

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 09:42

    At compile time. This is one of those most basic compiler optimizations, known as Constant Folding.

提交回复
热议问题