The invdivinv() function
The invdivinv() function divides an interval value by another interval value.
Syntax
mint invdivinv(i1, i2, num)
intrvl_t *i1, *i2;
double *num;
- i1
- A pointer to an interval variable that is the dividend.
- i2
- A pointer to an interval variable that is the divisor.
- num
- A pointer to the double value that is the quotient.
Usage
The invdivinv() function divides the interval value in i1 by i2, and stores the result in num. The result can be either positive or negative.
Both the input and output qualifiers must belong to the same interval class: either the year to month class or the day to fraction(5) class. If necessary, the invdivinv() function extends the interval value in i2 to match the qualifier for i1 before the division.
Return codes
- 0
- The division was successful.
- <0
- The division failed.
- -1200
- A numeric value is too large (in magnitude).
- -1201
- A numeric value is too small (in magnitude).
- -1266
- An interval value is incompatible with the operation.
- -1268
- A parameter contains an invalid interval qualifier.
Example
The demo directory
contains this sample program in the file invdivinv.ec.
/*
* invdivinv.ec *
The following program divides one interval value by another and
displays the resulting numeric value.
*/
#include <stdio.h>
EXEC SQL include datetime;
main()
{
mint x;
char out_str[16];
EXEC SQL BEGIN DECLARE SECTION;
interval hour to minute hrtomin1, hrtomin2;
double res;
EXEC SQL END DECLARE SECTION;
printf("INVDIVINV Sample ESQL Program running.\n\n");
printf("Interval #1 (hour to minute) = 75:27\n");
incvasc("75:27", &hrtomin1);
printf("Interval #2 (hour to minute) = 19:10\n");
incvasc("19:10", &hrtomin2);
printf("---------------------------------------------\n");
invdivinv(&hrtomin1, &hrtomin2, &res);
printf("Quotient (double) = %.1f\n", res);
printf("\nINVDIVINV Sample Program over.\n\n");
}
Output
INVDIVINV Sample ESQL Program running.
Interval #1 (hour to minute) = 75.27
Interval #2 (hour to minute) = 19:10
------------------------------------
Quotient (double) = 3.9
INVDIVINV Sample Program over.