# 2Q on No.

## Recommended Posts

I have two questions about numbers.

The first question is: How can I determine which is the smallest number from a group of three, aside from:

```If \$n1 < \$n2 and \$n1 < \$n3 Then
\$smallest = \$n1
EndIf
If \$n2 < \$n1 and \$n2 < \$n3 Then
\$smallest = \$n2
EndIf
If \$n3 < \$n1 and \$n3 < \$n2 Then
\$smallest = \$n3

?

And the second:

I divide to integrers. The result can be of any kind: integrer, real number, zecimal number etc.

How can I get everytime only the first digit and the next 2 zecimal digits?

Edited by Kiti

##### Share on other sites

I have two questions about numbers.

The first question is: How can I determine which is the smaller number from a group of three, aside from

If \$n1 < \$n2 and \$n1 < \$n3 Then

\$smallest = \$n1

EndIf

If \$n2 < \$n1 and \$n2 < \$n3 Then

\$smallest = \$n2

EndIf

If \$n3 < \$n1 and \$n3 < \$n2 Then

\$smallest = \$n3

EndIf

Like this:

```#include <Math.au3>
\$Min = _Min(_Min(\$nNum1,\$nNum2),\$nNum3)```

When the words fail... music speaks

##### Share on other sites

Hi,

put them into an array and then _arrayMin

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

##### Share on other sites

Thank you very much andreik !!

What about the 3 digits in any number? Can _arraytrimleft also return what it has trimmed? or maybe trim 4 character, add "0.00" and then make the division?

```\$no = 2.34765457
\$no1 = StringTrimLeft(\$no, 4) ;=>\$no1 = 765457
\$no2 = "0.00" & \$no1    ;=>\$no2 = 0.00765457
\$result = \$no-\$no2 ;  ;=> \$result =  2.34765457-0.00765457=2.34```

Any other more direct method ? muttley

##### Share on other sites

Thank you very much andreik !!

What about the 3 digits in any number? Can _arraytrimleft also return what it has trimmed? or maybe trim 4 character, add "0.00" and then make the division?

```\$no = 2.34765457
\$no1 = StringTrimLeft(\$no, 4) ;=>\$no1 = 765457
\$no2 = "0.00" & \$no1    ;=>\$no2 = 0.00765457
\$result = \$no-\$no2 ;  ;=> \$result =  2.34765457-0.00765457=2.34```

Any other more direct method ? muttley

Try this:

```Func MyFunc(\$NUM)
If IsInt(\$NUM) Then
Return \$NUM
Else
\$LEN = StringLen(String(\$NUM))
\$POINT = StringInStr(String(\$NUM),".")
Return StringLeft(String(\$NUM),\$POINT + 2)
EndIf
EndFunc```

When the words fail... music speaks

##### Share on other sites

Try this:

```Func MyFunc(\$NUM)
If IsInt(\$NUM) Then
Return \$NUM
Else
\$LEN = StringLen(String(\$NUM))
\$POINT = StringInStr(String(\$NUM),".")
Return StringLeft(String(\$NUM),\$POINT + 2)
EndIf
EndFunc```
Yayy!!! That's just perfect! Thank you very much! muttley

##### Share on other sites

Yayy!!! That's just perfect! Thank you very much! muttley

```Func MyFunc(\$NUM,\$DIGIT)
If IsInt(\$NUM) Then
Return \$NUM
Else
\$LEN = StringLen(String(\$NUM))
\$POINT = StringInStr(String(\$NUM),".")
Return StringLeft(String(\$NUM),\$POINT + \$DIGIT)
EndIf
EndFunc

MsgBox(-1,"",MyFunc(Random(1,1000),3))```

If you want more zecimal digits after point.

Edited by Andreik

When the words fail... music speaks

##### Share on other sites

Round???

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

##### Share on other sites

Round???

Yes. And more quick Round function. I don't use this function yet. muttley Edited by Andreik

When the words fail... music speaks

## Create an account

Register a new account

×

• Wiki

• Back

• Git