A method, apparatus, and computer instructions in a processor for
performing arithmetic operations. A data type associated with a
particular memory location is used to determine if an operation about to
be performed on the data in that location is legal. If the operation
requires the data to have a required data type, a determination is made
as to whether the operation is a legal operation based on the identified
data type and the required data type. If the operation is not legal on
the identified type, a determination is made as to whether data can be
cast to change the identified data type to the required data type. The
data is cast to the required data type if the data can be cast to form
modified data, and the arithmetic operation is performed on the modified
data. If the data cannot be cast to the Required type, an exception or
interrupt is generated.