# 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
##### Share on other sites

Something like this?

[font="Impact"]Never fear, I is here.[/font]

##### 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.

##### 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.
##### Share on other sites

That's what I was looking for...

THANKS!!!!

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...