Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static double getPPI(int w_pixels, int h_pixels, float diagonal_size) { if (w_pixels <= 0 || h_pixels <= 0 || diagonal_size <= 0) { return -1.0; } return Math.sqrt(w_pixels * w_pixels + h_pixels * h_pixels) / diagonal_size; } }