Floating point (j.3.6), Arrays and pointers (j.3.7), Arrays and pointers (f.3.7 of ansi c standard) – Echelon Neuron C User Manual

Page 254

Advertising
background image

242

Neuron C Language Implementation Characteristics

-128 .. 127

signed short

0 .. 255

unsigned short

-32768 .. 32767

signed long

0 .. 65535

unsigned long

All unsigned integer values use binary representations. Signed integers use

two’s complement binary representations. The long int, a multi-unit

representation, is stored such that the most significant byte is at the lowest
address.

Q: What is the sign of the remainder on integer division? (Sec. 3.3.5)

A:

The sign of the remainder of an integer division (that is, op1 % op2) is always

the same as the sign of op1.

Q: What is the result of a right shift of a negative-valued signed integral type?

(Sec. 3.3.7)

A:

When a negative-valued signed integral type is right-shifted, binary ones are

shifted in from the left. Thus, for int x and long int x, (x>>1) is always equal to
(x/2).

Floating Point (J.3.6)

Neuron C does not support floating-point operations with C syntax or operators.

A floating-point library is included with Neuron C that implements a limited set
of floating point operations as function calls. The floating-point library operates

on data that conforms to IEEE 754.

Arrays and Pointers (J.3.7)

Q: What is the result of casting a pointer to an integer, or vice versa? What is

the result of casting a pointer to one type to a pointer to another type? (Sec.

6.3.2.3)

A:

The binary representations of pointers and unsigned long integers are the

same. Thus, the result of casting a pointer to an integer of a certain type is the

same as casting an unsigned long to an integer of the same type. Integers cast to
pointer undergo the same conversions as integers cast to unsigned long.
All pointer representations are interchangeable. Thus, no conversion results

from casting a pointer to one type to a pointer to another type, and the use of
such a pointer produces the expected results.

Q: What is the type of integer required to hold the difference between two

pointers to elements of the same array,

ptrdiff_t

? (Secs. 6.5.6)

A:

The result of subtraction between two pointers is a [signed] long.

Arrays and Pointers (F.3.7 of ANSI C
Standard)

Q: What is the type of integer required to hold the maximum size of an array—

that is, the type of the sizeof operator,

size_t

? (Secs. 3.3.3.4, 4.1.1)

A:

The maximum size of an array (32,767 elements) requires an unsigned long.

Advertising