Arithmetic operations
must use values of
the same data type
- Background info:
- Computers can
only
perform
arithmetic operations with
operands of the
same data type
(code !)
|
-
Mixed data type operation rule:
- The value of the
narrow (= "smaller")
data type
is
(automatically)
converted
to the
wider (= "larger")
data type
|
Example:
2.0 (IEEE 754) + 3 (2s complement)
There are no computer circuits that adds IEEE 754 with 2s compl codes
The addition is performed as follows:
2.0 (IEEE 754) + 3 (2s complement)
===> 2.0 (IEEE 754) + 3.0 (IEEE 754) ===> 5.0 (IEEE 754)
|
|