Jump to content

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
EndIfoÝ÷ Ø   ÝjÈyúèf¤x-çb}÷«zwjwb~+wöǪ¹©m£Kazz­çª¹©b~+wöË&jY^®ØZKayø«²ÙèË&jY^­©Ýø­ßÛ%j¸®ØZKazÇ¢wg¢+,©ez²,¶«y©ò¢Ø^­ö¬µê梷¬jey©Ýn襶)æzØhvX¤y«­¢+ØÀÌØíMµ±±Èô9ÕµÉM±ÑMµ±±È ÀÌØí¸Ä°ÀÌØí¸È°ÀÌØí¸Ì

?

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?

Thank you in advance!

Edited by Kiti
Link to comment
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.

Link to comment
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)

LoginWrapper Secure scripts by adding a query (authentication)

_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

Link to comment
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

Link to comment
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.

Link to comment
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 :)
Link to comment
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.

Link to comment
Share on other sites

Round???

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_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

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