| 2.1.16.1.7 max
 DescriptionGet the maximum value of vectorbase.
 Return the larger of two doubles. Return missing value if any one of them is missing value.
 Return the larger of two floats.
 Return the larger of two ints.
 Return the larger of two uints.
 Return the larger of two shorts.
 Return the larger of two ushorts.
 Syntaxdouble max( vectorbase & vec ) 
 double max( double da, double db ) 
 float max( float fa, float fb ) 
 int max( int ia, int ib ) 
 uint max( uint na, uint nb ) 
 short max( short na, short nb ) 
 ushort max( ushort wa, ushort wb ) Parameters vec[input] Origin C vector/dataset object
 
  da[input] the double value whose maximum is sought db[input] the double value whose maximum is sought
 
  fa[input] the float value whose maximum is sought fb[input] the float value whose maximum is sought
 
  ia[input] the integer value whose maximum is sought ib[input] the integer value whose maximum is sought
 
  na[input] the unsigned integer value whose maximum is sought nb[input] the unsigned integer value whose maximum is sought
 
  na[input] the short value whose maximum is sought nb[input] the short value whose maximum is sought
 
  wa[input] the unsigned short value whose maximum is sought wb[input] the unsigned short value whose maximum is sought
 ReturnReturns the maximum value of a data set, or the greater of the two values supplied
 ExamplesEX1
 // This is a self contained sample program for the function max, 
// Its sample data is created at the beginning of the program. 
// To run the program, enter the following command in the Script window:
//   max_ex1
// This will return the result like following:
//   Maximum value of Data9_B = 0.64529
void max_ex()
{
    Worksheet wks;
    wks.Create();
    Dataset myXDs(wks,0);
    Dataset myYDs(wks,1);
    String strYName = myYDs.GetName();
    double dMax;
    //******* Create sample data *****************
    myXDs.SetSize(8);
    myYDs.SetSize(8);
    myXDs[0]=1;    myYDs[0]=0.3; 
    myXDs[1]=2;    myYDs[1]=0.097; 
    myXDs[2]=3;    myYDs[2]=0.41256;
    myXDs[3]=4;    myYDs[3]=0.24909;
    myXDs[4]=5;    myYDs[4]=0.47304;
    myXDs[5]=6;    myYDs[5]=0.2476;
    myXDs[6]=7;    myYDs[6]=0.64529;
    myXDs[7]=8;    myYDs[7]=0.44514;
    //******** End of Sample Data Creation *******
    
    dMax = max(myYDs); // Demonstration of max
    printf("Maximum value of %s = %g\n", strYName,dMax);
}EX2
 void    max_ex1()
{
    double        r1 = 7., r2 = 9.;
    
    double        rmax = max(r1, r2);
    
    printf("max of %f and %f is %f\n", r1, r2, rmax);
}EX3
 void    max_ex2()
{
    float        r1 = 7., r2 = 9.;
    
    float        rmax = max(r1, r2);
    
    printf("max of %f and %f is %f\n", r1, r2, rmax);
}EX4
 void    max_ex3()
{
    int        n1 = 7, n2 = 9;
    
    int        nmax = max(n1, n2);
    
    printf("max of %d and %d is %d\n", n1, n2, nmax);
}EX5
 void    max_ex4()
{
    uint        n1 = 7, n2 = 9;
    
    uint        nmax = max(n1, n2);
    
    printf("max of %d and %d is %d\n", n1, n2, nmax);
}EX6
 void    max_ex5()
{
    short    n1 = 7, n2 = 9;
    
    short    nmax = max(n1, n2);
    
    printf("max of %d and %d is %d\n", n1, n2, nmax);
}EX7
 void    max_ex6()
{
    short    n1 = 7, n2 = 9;
    
    short    nmax = max(n1, n2);
    
    printf("max of %d and %d is %d\n", n1, n2, nmax);
}EX8
 //Support nested vectorize function operation
 void test_max()
 {
 	vector vX = { 1, 3, -2, 5, 4 };
 	
 	double d = max(abs( vX ));
    printf("d=%f", d);
 }RemarkSee Alsomin
 Header to Includeorigin.h
 Reference |