This code returns -119… Wtf?
System.out.println(158 * 15000000/
16100000);
it prints -119 why does it do that?
Thanks in advance.
This code returns -119… Wtf?
System.out.println(158 * 15000000/
16100000);
it prints -119 why does it do that?
Thanks in advance.
try;
System.out.println("2147483647+1="+(2147483647+1));
2147483647+1=-2147483648
2147483647=0x7FFFFFFF
-2147483648=0x80000000
Signed ints use the top bit to indicate a -ve number.
Edit: Fix your problem with a cast to long;
System.out.println((long)158 * 15000000/16100000);
I thought java didnt use signed/unsigned?
And yes, your code worked. Thanks alot 
NP! Java doesn’t use unsigned - always a pain with bytes: 127+1=-128!