question: size of C# primitive data types according to ECMA standard

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Neil Zanella (nzanella_at_cs.mun.ca)
Date: 12/30/04


Date: 30 Dec 2004 15:17:42 -0800

Hello all,

In C and C++ a primitive data type is represented by a minimum number
of bits as defined by the corresponding standard. For instance an int
is assumed to be at least 16 bits on all platform where in practice
an int is 16 bits on the arcane 16 bit machines and 32 bits on the
most commonly used 32 bit machines.

However, my C# reference says that an int in C# is always 32 bits wide.
It also specifies a specific number of bits for all the other primitive
data types, namely bool, char, sbyte, byte, short, ushort, int, uint,
long, ulong, float, double, and decimal, where some of the corresponding
data types in C and C++ have minimum values but no fixed values. However
I have seen some C and C++ manuals make wrong claims about the width of
C and C++ data types as well.

So, I was just wondering whether anyone could please confirm whether the
C# standard defines fixed values for all primitives or whether this is
not so.

Thanks,

Neil



Relevant Pages

  • Re: question: size of C# primitive data types according to ECMA standard
    ... > of bits as defined by the corresponding standard. ... For instance an int ... > It also specifies a specific number of bits for all the other primitive ... > C# standard defines fixed values for all primitives or whether this is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: gmpy moving to code.google.com
    ... raise TypeError, "You can interact Decimal only with int, long ... or Decimal data types." ... You can interact Decimal only with int, ... data types. ...
    (comp.lang.python)
  • Re: Java Indexing- Historical question
    ... And when the array is of primitives there should be a dramatic benefit in memory usage as well. ... RestrictedRangeIntegerKeyedMapif you prefer) implements Mapthat only accepted keys in a given range, and stored its elements in an array. ... public ArrayMap(int base, int size) { ...
    (comp.lang.java.programmer)
  • Re: How to write better code for your projects ?
    ... >>it won't do any widening of data types. ... The compiler OTOH, thinks in terms of the internal word size ... > extern int x; ...
    (comp.arch.embedded)
  • Re: A Brief Look at History
    ... design graphics packages to draw a box you sure picked a loser for a ... Then why didn't Brodie use the more convenient primitives you suggested? ... I maintain that BOX2 is going to be far more effective ... void box2 (int l, int t, int r, int b) ...
    (comp.lang.forth)