Jump to content

math for changing a range of numbers?


Recommended Posts

I'm reading a variable that will be in the range of 0-200. I need to take the input of 0-200, and output 0-168.

Is there a math statement that I can apply to the input variable to get my adjusted output range?

The output range will be fixed when the project is complete, but during development, the upper limit may change. i.e. it may be 0-169, 0-170, etc.

Edited by SystemWontAccept
Link to comment
Share on other sites

That would work but I was wondering if there was a simple math way to accomplish it. Like...

Int ($InputVar - ($InputVar * (1-(168/200)) + 0.5))

My math just seems unnecessarily complicated. I was hoping a math geek out there could simplify this task.

If you omnly want to scale the output from the input then you don't want to take the result from the input.

$IPRANGE = 200
$OPRANGE = 168


$factor = $OPRANGE/$IPRANGE
$Outputvar = Ceiling($Inputvar*factor)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...