Source language: Translate to:

Ratio of any Two Numbers

General questions about NeoBook

Moderator: Neosoft Support

Ratio of any Two Numbers

Postby ajhunt » Sat Jun 25, 2016 4:37 am

Hi All, does anyone know of a way to find the ratio of two different numbers in an function please. As an example we all know 400x300 = 4:3, and 1600x900 = 16:9 (simply remove the 00's) but what about numbers like 1050x700 (which actually is 3:2 I believe). On paper can do it by finding common number but seeking a function or formular can use to see after a user types in their number it shows what ratio they are to each other. Any help appreciated. Many thyanks.
ajhunt
 
Posts: 215
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom

Re: Ratio of any Two Numbers

Postby Gaev » Sat Jun 25, 2016 4:59 am

ajhunt:

If you permit users to enter any two values (width, height), you can end up with ratios that are weird e.g. 745,701 could very well end up with a ratio of 745:701

You might be better off providing users with a dropdown/listbox of the most common screen resolutions ... and have them choose one that matches (or is the closest to) one of the choices.

This page ... http://www.w3schools.com/browsers/browsers_display.asp ... provides the ones used by 97% of this website's users.

This page ... https://en.wikipedia.org/wiki/Display_resolution ... provides screen pixels (and corresponding aspect ratios) for the common screen standards.

And another one here ... http://www.rapidtables.com/web/dev/scre ... istics.htm
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Ratio of any Two Numbers

Postby ajhunt » Sat Jun 25, 2016 8:00 am

Hi Gaev, that's my point as they can enter any numbers. They are resolutions of webcams and dlsr camera not screen resolutions and wanted to know what ratio they have chosen to capture their images at. With so many different cameras it makes it difficult to do a dropdown list. Thanks for your reply as always.
ajhunt
 
Posts: 215
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom

Re: Ratio of any Two Numbers

Postby Gaev » Sat Jun 25, 2016 8:34 am

ajhunt:

They are resolutions of webcams and dlsr camera not screen resolutions and wanted to know what ratio they have chosen to capture their images at. With so many different cameras it makes it difficult to do a dropdown list.


I am not familiar with aspect ratios deployed by webcams or dslr cameras.

But let us address this from another angle i.e. why exactly do you need the aspect ratio ? ... are you trying to map the output from such devices to a "rectangle on your screen" so that the result "does not appear skewed" ? ... if so, it would be a simple math formula ... given the width and height of the input stream ... and the "maximum available" width & height for output.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Ratio of any Two Numbers

Postby Peter » Mon Jun 27, 2016 2:27 am

ajhunt wrote:my point as they can enter any numbers.


Hi, ajhunt!

Try out this example, may be it's useful for you.

Regards,
Peter
User avatar
Peter
 
Posts: 29
Joined: Thu Sep 27, 2012 4:41 pm
Location: St.Petersburg, Russia

Re: Ratio of any Two Numbers

Postby ajhunt » Mon Jun 27, 2016 7:16 am

Hi Peter, many many thanks - it will work it perfectly. Gratefully received. :):):)
ajhunt
 
Posts: 215
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 4 guests