Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. int is always 32-bit?

int is always 32-bit?

Scheduled Pinned Locked Moved C#
question
15 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G George_George

    Hello everyone, When using "int", it is always 32-bit? No matter whether we make build option as Any CPU, x86 and x64? thanks in advance, George

    realJSOPR Offline
    realJSOPR Offline
    realJSOP
    wrote on last edited by
    #2

    If you want a larger (or smaller) integer, use Int64 or Int16. An int is as big as the compiler defines it to be.

    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
    -----
    "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

    G M 2 Replies Last reply
    0
    • realJSOPR realJSOP

      If you want a larger (or smaller) integer, use Int64 or Int16. An int is as big as the compiler defines it to be.

      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

      G Offline
      G Offline
      George_George
      wrote on last edited by
      #3

      Thanks John, Answer to my original question is, int is always 32-bit no matther what platform and build option (Any CPU/x86/x64) is used? :-) regards, George

      realJSOPR 1 Reply Last reply
      0
      • G George_George

        Thanks John, Answer to my original question is, int is always 32-bit no matther what platform and build option (Any CPU/x86/x64) is used? :-) regards, George

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #4

        no. visual c++ 1.2 (and turbo pascal) defined an int as 16-bit. Starting with Visual C++ 2.0, an int was 32 bit.

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        G 1 Reply Last reply
        0
        • G George_George

          Hello everyone, When using "int", it is always 32-bit? No matter whether we make build option as Any CPU, x86 and x64? thanks in advance, George

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #5

          George_George wrote:

          When using "int", it is always 32-bit?

          Yes. In C# an int is always 32 bits. The keyword int is an alias for the type System.Int32.

          Despite everything, the person most likely to be fooling you next is yourself.

          G 1 Reply Last reply
          0
          • G George_George

            Hello everyone, When using "int", it is always 32-bit? No matter whether we make build option as Any CPU, x86 and x64? thanks in advance, George

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            int in C# = 32-bit[^]

            G 1 Reply Last reply
            0
            • G George_George

              Hello everyone, When using "int", it is always 32-bit? No matter whether we make build option as Any CPU, x86 and x64? thanks in advance, George

              E Offline
              E Offline
              ElSpinos
              wrote on last edited by
              #7

              Just to add to the pot: The C# keyword int is a compiler accessor to the System.Int32 type. You may use the below code to validate this as an excercise on each platform:

              typeof(int) == typeof(System.Int32)

              The above code will return true.

              /F - .NET Developer

              G 1 Reply Last reply
              0
              • realJSOPR realJSOP

                If you want a larger (or smaller) integer, use Int64 or Int16. An int is as big as the compiler defines it to be.

                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #8

                John Simmons / outlaw programmer wrote:

                An int is as big as the compiler defines it to be

                Wrong language John? :)

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                G 1 Reply Last reply
                0
                • G George_George

                  Hello everyone, When using "int", it is always 32-bit? No matter whether we make build option as Any CPU, x86 and x64? thanks in advance, George

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #9

                  Ayuh http://msdn.microsoft.com/en-us/library/hfa3fa08.aspx[^]

                  G 1 Reply Last reply
                  0
                  • realJSOPR realJSOP

                    no. visual c++ 1.2 (and turbo pascal) defined an int as 16-bit. Starting with Visual C++ 2.0, an int was 32 bit.

                    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                    -----
                    "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                    G Offline
                    G Offline
                    George_George
                    wrote on last edited by
                    #10

                    Thanks John, My context is C#. Any comments or answers to my original question? regards, George

                    1 Reply Last reply
                    0
                    • G Guffa

                      George_George wrote:

                      When using "int", it is always 32-bit?

                      Yes. In C# an int is always 32 bits. The keyword int is an alias for the type System.Int32.

                      Despite everything, the person most likely to be fooling you next is yourself.

                      G Offline
                      G Offline
                      George_George
                      wrote on last edited by
                      #11

                      Cool, thanks Guffa! regards, George

                      1 Reply Last reply
                      0
                      • M Mark Salsbery

                        John Simmons / outlaw programmer wrote:

                        An int is as big as the compiler defines it to be

                        Wrong language John? :)

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        G Offline
                        G Offline
                        George_George
                        wrote on last edited by
                        #12

                        Yes, it is C# forum. :-) regards, George

                        1 Reply Last reply
                        0
                        • L Lost User

                          int in C# = 32-bit[^]

                          G Offline
                          G Offline
                          George_George
                          wrote on last edited by
                          #13

                          Good link, thanks Greeeg! regards, George

                          1 Reply Last reply
                          0
                          • E ElSpinos

                            Just to add to the pot: The C# keyword int is a compiler accessor to the System.Int32 type. You may use the below code to validate this as an excercise on each platform:

                            typeof(int) == typeof(System.Int32)

                            The above code will return true.

                            /F - .NET Developer

                            G Offline
                            G Offline
                            George_George
                            wrote on last edited by
                            #14

                            Cool, thanks ElSpinos! regards, George

                            1 Reply Last reply
                            0
                            • P PIEBALDconsult

                              Ayuh http://msdn.microsoft.com/en-us/library/hfa3fa08.aspx[^]

                              G Offline
                              G Offline
                              George_George
                              wrote on last edited by
                              #15

                              Good link, thanks PIEBALDconsult! regards, George

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups