Looks like there is issue with java's Math.round
function, when passing integer value to it.
I ran it for couple of inputs but giving suprisingly wrong results.
Sample Code:
public static void main(String[] args) {
System.out.println("roundOff1: " + Math.round(1669053278));
System.out.println("roundOff2: " + Math.round(1669053304));
System.out.println("roundOff3: " + Math.round(1669053314));
System.out.println("roundOff4: " + Math.round(1669053339));
}
Stdout:
roundOff1: 1669053312
roundOff2: 1669053312
roundOff3: 1669053312
roundOff4: 1669053312
My use case was to round of the System.currentTimeMillis()/1000
but end in getting wrong result.
Did I really found a bug in Java or missing something here?