Given a list of screen sizes, how do I detect which ones are in 4:3 16:9 aspect ratio? I can use width / height to get it but for 16:9 sizes I sometimes get 1.778 and sometimes I get 1.777778 due to rounding errors.
Check if 4 * height == 3 * width
or 16 * height == 9 * width
.
Remember the definition of a rational number: It is an equivalence class of pairs of integers (m, n) subject to the equivalence (m, n) ≡ (m', n') if and only if n' m = n m'.