# Number to Percent?

## Recommended Posts

Basically I want to make a number equal 100% and if that number lets say drops 20% then do something..

So,

```\$num = 1234

If \$num < 80% Then Call("bob")```

SOmething in that manner.. Is it possible and how would I do it?

##### Share on other sites

It's a pretty basic math formula... (x / y ) * 100 = %

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

##### Share on other sites

\$num = 345

\$pct = 80

\$oldnum = \$num

; Do some stuff that changes the value of \$num

If \$num < \$oldnum*\$pct/100 Then

; Do something else

EndIf

Something like that?

EDIT: added the phrase "that changes the value of \$num"

Edited by Smed

601DisengageEnd Program

##### Share on other sites

nope... test value is always the same as present value. If you need to know that its changed you must preserve the old value. The test you presented will always fail.

601DisengageEnd Program

##### Share on other sites

MsgBox will fire when \$x is exactly 80, but I think you have the right idea now.

601DisengageEnd Program

##### Share on other sites

```\$baseline = 100; 100%
\$threshold = (\$baseline * .80); set threshold at 80%
if \$baseline <= \$threshold Then
EndIf```

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

##### Share on other sites

```\$baseline = 100; 100%
\$threshold = (\$baseline * .80); set threshold at 80%
if \$baseline <= \$threshold Then
EndIf```

<{POST_SNAPBACK}>

I was going to tell you were correct, but you deleted your last post before i could.

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

I would:

```;\$x is the starting number
\$x / .8 = \$y

If \$x < \$y Then
;......
EndIf```

At least something like that.

Edit: Nvm, thats a variable, lol...

Edited by gamerman2360

##### Share on other sites

I was going to tell you were correct, but you deleted your last post before i could.

<{POST_SNAPBACK}>

I had trouble following it that way...so i put it in terms I'm familiar with...

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...