This will be short and simple but some math that hopefully will be helpful. I have been doing a lot of mobile device detection work as of late. Recently I was about to get the physical width and height of a device in millimeters. This was great but what I really needed was the diagonal screen size in inches. Here is the math for it.
- Get the width in inches : width in millimeters times 0.0393700787
- Get the height in inches : height in millimeters times 0.0393700787
- Combined value of both to the power of 2 : width in inches ^2 + height in inches^2
- Get the square root which should be the diagonal screen size : Combined value square root
That is it.
You can see it working on my test site
Comments