// The number here respresents accuracy. Low-accuracy is good.
// The lower the accuracy, the higher chance we have of getting a close match.
const makeComparisonFloat = (float) => Math.round(float * 10)
const ratio = makeComparisonFloat(width / height)
return aspectRatios.find((option) => makeComparisonFloat(option.ratio) === ratio)
2条答案
按热度按时间bhmjp9jg1#
你可以简单地把它们分开,这样就给予了比率...
rryofs0p2#
您可以简单地将它们彼此分开,如用户 caramba 所述:
...但有时您可能希望比较接近但不完全存在的值。
为此,您应该执行以下操作: