User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:max [2019/07/14 17:00]
cl:functions:max [2019/07/17 21:00] (current)
Line 1: Line 1:
 +====== Function MAX, MIN ======
 +
 +====Syntax====
 +  * **max** //''&​rest''​ reals''​+''//​ → //​max-real// ​
 +  * **min** //''&​rest''​ reals''​+''//​ → //​min-real//​
 +
 +====Arguments and Values====
 +  * //real// - a //​[[CL:​Glossary:​real]]//​.
 +  * //​max-real//,​ //​min-real//​ - a //​[[CL:​Glossary:​real]]//​.
 +
 +====Description====
 +**max** returns the //real// that is greatest (closest to positive infinity). **min** returns the //real// that is least (closest to negative infinity).
 +
 +For **max**, the implementation has the choice of returning the largest argument as is or applying the rules of floating-point //​[[CL:​Glossary:​contagion]]//,​ taking all the arguments into consideration for //​[[CL:​Glossary:​contagion]]//​ purposes. Also, if one or more of the arguments are **[[CL:​Functions:​math-equal|=]]**,​ then any one of them may be chosen as the value to return. For example, if the //reals// are a mixture of //​[[CL:​Glossary:​rationals]]//​ and //​[[CL:​Glossary:​floats]]//,​ and the largest argument is a //​[[CL:​Glossary:​rational]]//,​ then the implementation is free to produce either that //​[[CL:​Glossary:​rational]]//​ or its //​[[CL:​Glossary:​float]]//​ approximation;​ if the largest argument is a //​[[CL:​Glossary:​float]]//​ of a smaller format than the largest format of any //​[[CL:​Glossary:​float]]//​ argument, then the implementation is free to return the argument in its given format or expanded to the larger format. Similar remarks apply to **min** (replacing "​largest argument"​ by "​smallest argument"​).
 +
 +====Examples====
 +<​blockquote>​
 +(max 3) <r>3 </r>
 +(min 3) <r>3 </r>
 +(max 6 12) <r>12 </r>
 +(min 6 12) <r>6 </r>
 +(max -6 -12) <r>-6 </r>
 +(min -6 -12) <​r>​-12 </r>
 +(max 1 3 2 -7) <r>3 </r>
 +(min 1 3 2 -7) <r>-7 </r>
 +(max -2 3 0 7) <r>7 </r>
 +(min -2 3 0 7) <r>-2 </r>
 +(max 5.0 2) <​r>​5.0 </r>
 +(min 5.0 2) <​r>​2 ​
 +//or// 2.0 </r>
 +(max 3.0 7 1) <​r>​7 ​
 +//or// 7.0 </r>
 +(min 3.0 7 1) <​r>​1 ​
 +//or// 1.0 </r>
 +(max 1.0s0 7.0d0) <​r>​7.0d0 </r>
 +(min 1.0s0 7.0d0) <​r>​1.0s0 ​
 +//or// 1.0d0 </r>
 +(max 3 1 1.0s0 1.0d0) <​r>​3 ​
 +//or// 3.0d0 </r>
 +(min 3 1 1.0s0 1.0d0) <​r>​1 ​
 +//or// 1.0s0 
 +//or// 1.0d0 </r>
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +Should signal an error of //​[[CL:​Glossary:​type]]//​ **[[CL:​Types:​type-error]]**if //number// is not a //​[[CL:​Glossary:​real]]//​.
 +
 +====See Also====
 +None.
 +
 +====Notes====
 +None.