2.1.16.1.9 min
Description
Get the minimum value of vectorbase.
Return the smaller of two doubles, return missing value if any one of them is missing value.
Return the smaller of two floats.
Return the smaller of two ints.
Return the smaller of two uints.
Return the smaller of two shorts.
Return the smaller of two ushorts.
Syntax
double min( vectorbase & vec )
double min( double da, double db )
float min( float fa, float fb )
int min( int ia, int ib )
uint min( uint na, uint nb )
short min( short na, short nb )
ushort min( ushort wa, ushort wb )
Parameters
- vec
- [input] Origin C vector/dataset object
- da
- [input] the double value whose minimum is sought
- db
- [input] the double value whose minimum is sought
- fa
- [input] the float value whose minimum is sought
- fb
- [input] the float value whose minimum is sought
- ia
- [input] the integer value whose minimum is sought
- ib
- [input] the integer value whose minimum is sought
- na
- [input] the unsigned integer value whose minimum is sought
- nb
- [input] the unsigned integer value whose minimum is sought
- na
- [input] the short value whose minimum is thought
- nb
- [input] the short value whose minimum is thought
- wa
- [input] ushort values that compare
- wb
- [input] ushort values that compare
Return
Returns the minimum value of a data set, or the smaller of the two values supplied
Examples
EX1
// This is a self contained sample program for the function min,
// Its sample data is created at the beginning of the program.
// To run the program, enter the following command in the Script window:
// min_ex1
// This will return the result like following:
// Minimum value of Data5_B = 0.097
void min_ex1()
{
Worksheet wks;
wks.Create();
Dataset myXDs(wks,0);
Dataset myYDs(wks,1);
string strYName = myYDs.GetName();
double dMin;
//******* 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 *******
dMin = min(myYDs); // Demonstration of min
printf("Minimum value of %s = %g\n", strYName,dMin);
}
EX2
void min_ex2()
{
double r1 = 7., r2 = 9.;
double rmin = min(r1, r2);
printf("min of %f and %f is %f\n", r1, r2, rmin);
}
EX3
void min_ex3()
{
float r1 = 7., r2 = 9.;
float rmin = min(r1, r2);
printf("min of %f and %f is %f\n", r1, r2, rmin);
}
EX4
void min_ex4()
{
int n1 = 7, n2 = 9;
int nmin = min(n1, n2);
printf("min of %d and %d is %d\n", n1, n2, nmin);
}
EX5
void min_ex5()
{
uint n1 = 7, n2 = 9;
uint nmin = min(n1, n2);
printf("min of %d and %d is %d\n", n1, n2, nmin);
}
EX6
void min_ex6()
{
short n1 = 7, n2 = 9;
short nmin = min(n1, n2);
printf("min of %d and %d is %d\n", n1, n2, nmin);
}
EX7
void min_ex7()
{
ushort n1 = 7, n2 = 9;
ushort nmin = min(n1, n2);
printf("min of %d and %d is %d\n", n1, n2, nmin);
}
Remark
See Also
max
Header to Include
origin.h
Reference
|