SCREEN SIZE CALCULATOR






Screen Size Calculator


Screen Size Calculator




// Validate inputs
if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0) { alert('Please enter valid screen dimensions'); return; } // Calculate diagonal size using Pythagorean theorem const diagonalSize = Math.sqrt(width * width + height * height) / (ppi || 1); // Calculate aspect ratio const gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
const divisor = gcd(width, height);
const aspectRatioWidth = width / divisor;
const aspectRatioHeight = height / divisor;

// Display results
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = `

Screen Details

Screen Dimensions: ${width} x ${height} pixels

Diagonal Size: ${diagonalSize.toFixed(2)} inches

Aspect Ratio: ${aspectRatioWidth}:${aspectRatioHeight}

Pixel Density: ${ppi ? ppi + ' PPI' : 'Not specified'}

`;
}