objective c - How to convert a number range from 0-200 into 1-5 range -


i have value 0 200 0 better quality , 200 worst quality.

how convert (in obj-c/cocoa framework) integer 0-5 being 5 best?.

for example 200 0 , 0 5.

hopefully rounding works here:

int input; int output = 5 - (int)floorf( ((float)input)/40.0f); 

you may same results doing

int output = 5 - (input/40); 

but depends on compiler's math settings.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -