How get result from php the same on java?

Vaagn Stepanian :

Why on php this printf((2376995291 - 141 * 16777216) / 65535) on

result 174.0724040589.

On Java System.out.println((2376995291L - 141 * 16777216) / 65535)

result 65711 .

Why its two different result and how get result PHP on Java , i need get 174 on java.

vivek_23 :
System.out.println((2376995291L - 141L * 16777216L) / (double)65535);

141 * 16777216 will technically overflow since it's greater than 2^31 - 1. So, make them as long numbers to avoid overflow and you could typecast the denominator if you like to get the result with decimal points as well.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=128134&siteId=1