Greetings, This method is overloaded to take int,long,double,float argument. If the argument is Long.MIN_VALUE then compiler gives the following error. A1.java:3: integer number too large: -9223372036854775808 System.out.println(Math.abs(-9223372036854775808)); ^ He is an example,
What am I missing here? Thanks, Asha Edited by Corey McGlone: Added CODE Tags. [ February 02, 2004: Message edited by: Corey McGlone ]
Actually, it isn't the abs method that is producing the error. The problem is that, in Java, any numeric literal, including -9223372036854775808, is interpreted as an integer. Obviously, that number doesn't fit into an integer. Therefore, if you want that line to compile properly, you need to let the compiler know that this number is a long, not an integer, like this:
Notice the 'l' on the end of that number (that's a lower case L in case you can't see it well)? That let's the compiler know that it should interpret this value as a long, not an int. Do that, and your code will work fine...sort of. You might want to see the resulting value and make sure you can explain that...