Here you can find the source of abs(double x)
public static double abs(double x)
//package com.java2s; public class Main { public static double abs(double x) { if (x >= 0) return x; else//from w w w . j ava 2s .c o m return -x; } public static int abs(int x) { if (x >= 0) return x; else return -x; } }