MAX/de
From MCS Wiki AVR
< MAX
Revision as of 01:22, 10 March 2013 by Stefanhamburg (Talk | contribs)
Contents |
= (**COPIED FROM ENGLISH PAGE**) === Action
Returns the maximum value of a byte or word array.
Syntax
var1 = MAX(var2)
MAX(ar(1), m ,idx)
Remarks
var1 |
Variable that will be assigned with the maximum value. |
var2 |
The first address of the array. |
|
|
|
The MAX statement can return the index too |
Ar(1) |
Starting element to get the maximum value and index of. |
M |
Returns the maximum value of the array. |
Idx |
Return the index of the array that contains the maximum value. Returns 0 if there is no maximum value. |
The MIN() and MAX() functions work on BYTE and WORD arrays only.
See also
Beispiel
'----------------------------------------------------------------------------------------- 'name : minmax.bas 'copyright : (c) 1995-2005, MCS Electronics 'purpose : show the MIN and MAX functions 'micro : Mega48 'suited for demo : yes 'commercial addon needed : no '----------------------------------------------------------------------------------------- $regfile = "m48def.dat" ' Mikrocontroller $crystal = 4000000 ' Taktfrequenz $baud = 19200 ' Baudrate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 ' default use 40 for the frame space ' Diese Funktionen arbeiten nur mit BYTE- und WORD-Arrays !!!!! 'Dim some variables Dim Wb As Byte , B As Byte Dim W(10) As Word ' oder benutzen Sie ein Byte-Array 'Füllen des Word-Arrays mit Werten von 1 bis 10 For B = 1 To 10 W(b) = B Next Print "Max number " ; Max(w(1)) Print "Min number " ; Min(w(1)) Dim Idx As Word , M1 As Word Min(w(1) , M1 , Idx) Print "Min number " ; M1 ; " index " ; Idx Max(w(1) , M1 , Idx) Print "Max number " ; M1 ; " index " ; Idx End
Languages | English • Deutsch |
---|