Results 1 to 10 of 10

Thread: Numeric data types

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Numeric data types

    What is better to use in .net ?

    Integer Vs Int32
    Short Vs Int16
    etc

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Integers. Most CPUs are 32 bit, so each time you wish to do a calculation on a 32 bit value, the whole thing is pushed into the CPU register. where as using 16 bit, it either has to buffer it out, or wait for 2 of them before it deals with it.

    Well, thats what I read anyway .

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    no that wasn't my question. Sorry maybe I wasn't clear

    I meant what is more efficent to use

    Integer
    or
    Int32

    and

    Short
    or
    Int16

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    I "believe" that the Integer is a wrapper for Int32, because Ive heard that on a 32 bit OS it uses an Int32 and that on a 64 bit uses it as an Int64. Ive never had the chance to try it.

    As for short and Int16, I would have thought they are the same thing, but I know MS suggest you use Int16 as its the base .net name and Short is the VB shortcut. But at compile time I spose its the same thing.

    If you find a better explaination do tell .

  5. #5
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Just had a search, and it seems that the Integer is just mapped directly to Int32 currently, and that the Int64 thing is probly just a rumour .
    So they are both the same, use what you prefer is the general reply.

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Integer is mapped to the base class Int32 . Whether you use Integer or Int32 , it will be converted to IL that says Int32 .

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Int32 is explicitly 4 bytes long.

    Integer is not. It presently exists as a 32bit variable on today's framework. Not necessarily true 3 years from now. I guess it was to allow for expansion on to future OS's.... but as Pirate points out, in this framework, it seems to map to Int32.

    But I don't have a 64bit OS to compile it on, or a future version of the framework to test it on, so...

    http://blogs.msdn.com/duncanma/archi...4/06/4927.aspx
    Last edited by nemaroller; Jul 21st, 2004 at 12:27 PM.

  8. #8

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    im not concerned so much with the int64 which is why i didnt mention it in the post.

    Im just converting some VB6 classes and was wondering what data types I should use for my integers and longs if I should use short and integer or int16 and int32

  9. #9
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Int64 isn't a long?
    \m/\m/

  10. #10
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    My advice... based off that msdn blog..

    Use Integer in all cases unless you're going to be passing them as parameters to a Win32 API (or other libraries which explicitly expect a 4-bit Integer , and pass it an Int32 in those cases).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width