[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Gm2] More about LONGINT fixes

**From**: |
Gaius Mulley |

**Subject**: |
Re: [Gm2] More about LONGINT fixes |

**Date**: |
22 Nov 2004 11:52:46 +0000 |

**User-agent**: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |

Izo <address@hidden> writes:
>* Gaius Mulley wrote:*
>* *
>* >Hi,*
>* >*
>* >I believe I've fixed LONGINT constant for an opteron based system..*
>* >It is slightly more tricky for 32 bit systems due to the data type*
>* >correspondence between C and Modula-2 which is outlined below:*
>* >*
>* >GNU Modula-2 GNU C*
>* >======================================*
>* >...*
>* >CARDINAL unsigned int*
>* >LONGCARD long unsigned int*
>* >SHORTCARD short unsigned int*
>* >BOOLEAN int*
>* >.....*
>* >*
>* *
>* I am not quite sure that this is true. I have to check, but I think*
>* that the C's unsigned int only takes the positive part of the signed*
>* int, which means that the GNU M2's CARDINAL would have the range*
>* 0..7FFFFFFF instead of 0..FFFFFFFF. The similar would then apply to*
>* the LONGCARD and SHORTCARD.*
Practically in GCC I believe it does use the full range for an
unsigned int. It does seem as if C supports CARDINAL via this
construct. The reference manual p196 in "Programming in C (ANSI
Ed)", 1990 says:
"Unsigned integers, declared using the keyword unsigned, obey the laws
of arithmetic modulo 2^n where n is the number of bits in a
representation, and thus arithmetic on unsigned quantities can never
overflow. The set of non-negative values that can be stored in a
signed object is a subset of the values that can be stored in the
corresponding unsigned object, and the representation for the
overlapping values is the same."
>* And for the BOOLEAN. It is true, indeed that the size of BOOLEAN is*
>* not defined by standard but left to be defined by design. Yet, my*
>* opinion would be that for the sake of the language intercompatibility*
>* would be the best to define the BOOLEAN as char. At least through*
>* special compiler option ?*
yes this is probably the right thing to do.
regards,
Gaius