# <!-- var kmNextPage = "armcc_chr1360774870320.htm"; var kmPrevPage = "armcc_chr1359125009502.htm"; var kmNextPageTitle = "Structures, unions, enumerations, and bitfields in"; var kmPrevPageTitle = "Basic data types in ARM C and C++"; var kmBreadCrumbs = "<a href=\"default.htm\">Home</a> &raquo; <a href=\"armcc_chr1359125008566.htm\">C and C++ Implementation Details</a> &raquo; Operations on basic data types ARM C and C++"; kmSetupPaging (); kmNavButtons(); //--> Operations on basic data types ARM C and C++

## 10.3 Operations on basic data types ARM C and C++

Describes the basic data type arithmetic operation implementation details in ARM C and C++.

The ARM compiler performs the usual arithmetic conversions set out in relevant sections of the ISO C99 and ISO C++ standards. The following information describes additional points that relate to arithmetic operations.

## Operations on integral types

The following statements apply to operations on the integral types:
• All signed integer arithmetic uses a two's complement representation.
• Bitwise operations on signed integral types follow the rules that arise naturally from two's complement representation. No sign extension takes place.
• Right shifts on signed quantities are arithmetic.
• The remainder on integer division has the same sign as the numerator, as required by the ISO C99 standard.
• If a value of integral type is truncated to a shorter signed integral type, the result is obtained by discarding an appropriate number of most significant bits. If the original number is too large, positive or negative, for the new type, there is no guarantee that the sign of the result is going to be the same as the original.
• A conversion between integral types does not raise an exception.

## Operations on floating-point types

The following statements apply to operations on floating-point types:
• Normal IEEE 754 rules apply.
• Rounding is to the nearest representable value by default.
• Floating-point exceptions are disabled by default.

### Note

The IEEE 754 standard for floating-point processing states that the default action to an exception is to proceed without a trap. You can modify floating-point error handling by tailoring the functions and definitions in fenv.h.

## Pointer subtraction

The following statements apply to all pointers in C. They also apply to pointers in C++, other than pointers to members:
• When one pointer is subtracted from another, the difference is the result of the expression:
`((int)a - (int)b) / (int)sizeof(type pointed to)`
• If the pointers point to objects whose alignment is the same as their size, this alignment ensures that division is exact.
• If the pointers point to objects whose alignment is less than their size, such as packed types and most `struct`s, both pointers must point to elements of the same array.
 Non-Confidential PDF version ARM DUI0375H Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved.

##### Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

##### Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.