BOOTSTRAP (klibm) functions


LIBRARY ROUTINE

kdatatype_cast_process - cast type for processing

LIBRARY CALL

int kdatatype_cast_process(
   int type1,
   int type2,
   int return_values)

INPUT

OUTPUT

none

RETURN VALUE

The recommended data type.

DESCRIPTION

The routine is used to recommend an appropriate common data type to be used as when processing data. What this routine does is examine the input data types for precision, sign, range, etc. and recommends one of four data types that can be used with minimal risk of destroying data integrity if the variable return_values is KANYTYPE. The values are KLONG, KULONG, KDOUBLE, or KDCOMPLEX. If the variable return_values is not KANYTYPE this routine will return only one of the data types specified. To specify more than one posible return value you must OR the data types together:

proc_type = kdatatype_cast_process(type1, type2, KUBYTE | KDOUBLE);

Any number of data types can be specified. This routine will always try to return the data type that will not destroy data integrity. However, it will never return a data type not specified in return_values. It is up to the programmer to ensure that the data type specified by the return value either preserves the data integrity or handles the loss in data integrity properly.

For example, you would lose data integrity if you called this routine in the following manner :

proc_type = kdatatype_cast_process(KUBYTE, KSHORT, KUBYTE | KUSHORT);

Return_values = KUBYTE | KUSHORT, the returned value will be KUSHORT, but since KSHORT means that negative numbers are posible the data processing the data as KUSHORT will not not reflect this properly. The call should OR KINT or KLONG data type so that negative numbers are processed as negative numbers. However, as stated above it is up to the programmer to specify the return_values so that data integrity is preserved or handles this lose in there processing routine correctly.

If either of the types is KSTRING or KSTRUCT than KNONE is returned.

ADDITIONAL INFORMATION

none

EXAMPLES

none

SIDE EFFECTS

none

RESTRICTIONS

none

MODIFICATION

none

FILES

$BOOTSTRAP/objects/library/klibm/src/kdata_type.c

SEE ALSO

klibm(3)

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.