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. The Lounge
  3. This isn't true is it?

This isn't true is it?

Scheduled Pinned Locked Moved The Lounge
question
20 Posts 8 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.
  • E Offline
    E Offline
    eggie5
    wrote on last edited by
    #1

    The number of bytes used by an int variable is the same on any computer. /\ |_ E X E GG

    J M M L 4 Replies Last reply
    0
    • E eggie5

      The number of bytes used by an int variable is the same on any computer. /\ |_ E X E GG

      J Offline
      J Offline
      Jeff Varszegi
      wrote on last edited by
      #2

      In Java or .NET, yep. Are you still studying for your Java test? If so, definitely. -Jeff here, bloggy bloggy

      E 1 Reply Last reply
      0
      • E eggie5

        The number of bytes used by an int variable is the same on any computer. /\ |_ E X E GG

        M Offline
        M Offline
        Maxwell Chen
        wrote on last edited by
        #3

        No, it is false. The key factor is the endian in various CPUs. Reference: Endian[^]. [Edit]Sorry I might have misunderstood your question. If you are asking the size of int... It's 2 bytes in Win16; 4 bytes in Win32, and 4 bytes in Win64.[/Edit] Maxwell Chen

        E 1 Reply Last reply
        0
        • M Maxwell Chen

          No, it is false. The key factor is the endian in various CPUs. Reference: Endian[^]. [Edit]Sorry I might have misunderstood your question. If you are asking the size of int... It's 2 bytes in Win16; 4 bytes in Win32, and 4 bytes in Win64.[/Edit] Maxwell Chen

          E Offline
          E Offline
          eggie5
          wrote on last edited by
          #4

          I knew it, I read it somewhere before. This book i'm reading for my test says it's true! /\ |_ E X E GG

          M 1 Reply Last reply
          0
          • J Jeff Varszegi

            In Java or .NET, yep. Are you still studying for your Java test? If so, definitely. -Jeff here, bloggy bloggy

            E Offline
            E Offline
            eggie5
            wrote on last edited by
            #5

            This book says it's true. That's a bunch of crap... Oh, well, I guess I have to go with it. Look at what they're teaching kids these days! /\ |_ E X E GG

            J T 2 Replies Last reply
            0
            • E eggie5

              I knew it, I read it somewhere before. This book i'm reading for my test says it's true! /\ |_ E X E GG

              M Offline
              M Offline
              Maxwell Chen
              wrote on last edited by
              #6

              What book are you reading? Would you please quote what it says in the book for that? Thanks. Maxwell Chen

              E 1 Reply Last reply
              0
              • E eggie5

                This book says it's true. That's a bunch of crap... Oh, well, I guess I have to go with it. Look at what they're teaching kids these days! /\ |_ E X E GG

                J Offline
                J Offline
                Jeff Varszegi
                wrote on last edited by
                #7

                It is true. No matter on what machine or OS .NET and/or Java are implemented, their platform specifications state unequivocally that each int will have four bytes. This has nothing to do with the operating system or anything else. -Jeff here, bloggy bloggy

                E 1 Reply Last reply
                0
                • J Jeff Varszegi

                  It is true. No matter on what machine or OS .NET and/or Java are implemented, their platform specifications state unequivocally that each int will have four bytes. This has nothing to do with the operating system or anything else. -Jeff here, bloggy bloggy

                  E Offline
                  E Offline
                  eggie5
                  wrote on last edited by
                  #8

                  What about different CPUs? /\ |_ E X E GG

                  J M D 3 Replies Last reply
                  0
                  • E eggie5

                    What about different CPUs? /\ |_ E X E GG

                    J Offline
                    J Offline
                    Jeff Varszegi
                    wrote on last edited by
                    #9

                    It doesn't matter. It could be a 256-bit UberXeon from planet Xanax. Think of even Java and .NET primitive types as being abstractions of how the data's represented on the particular hardware, etc. -Jeff here, bloggy bloggy

                    E 1 Reply Last reply
                    0
                    • E eggie5

                      What about different CPUs? /\ |_ E X E GG

                      M Offline
                      M Offline
                      Maxwell Chen
                      wrote on last edited by
                      #10

                      I think that the Java Virtual Machine does the job to convert the order in different endians to Java desired endian. Maxwell Chen

                      1 Reply Last reply
                      0
                      • M Maxwell Chen

                        What book are you reading? Would you please quote what it says in the book for that? Thanks. Maxwell Chen

                        E Offline
                        E Offline
                        eggie5
                        wrote on last edited by
                        #11

                        Litvin, Maria. Be Prepared for the AP Computer Science Exam in Java. Andover, MA: 2003.

                        14. Which of the following statements about Java's platform independence are true?

                        I. The number of bytes used by an int variable is the same on any computer.

                        II. Java source code is complied into bytecodes, which may then be run on any computer with the Java Virtual Machine installed.

                        III. Overflow in arithmetic operations occurs at the same values regardless of the platform on which the Java program is running.

                        (A) I only
                        (B) II only
                        (C) I and II
                        (D) II and III
                        (E) I, II, and III

                        /\ |_ E X E GG

                        M 1 Reply Last reply
                        0
                        • J Jeff Varszegi

                          It doesn't matter. It could be a 256-bit UberXeon from planet Xanax. Think of even Java and .NET primitive types as being abstractions of how the data's represented on the particular hardware, etc. -Jeff here, bloggy bloggy

                          E Offline
                          E Offline
                          eggie5
                          wrote on last edited by
                          #12

                          this is madness. /\ |_ E X E GG

                          J 1 Reply Last reply
                          0
                          • E eggie5

                            this is madness. /\ |_ E X E GG

                            J Offline
                            J Offline
                            Jeff Varszegi
                            wrote on last edited by
                            #13

                            You're not the first person to say that, but think of it this way: it would be hard to make a claim like "write once, run anywhere" if the code could behave differently on different platforms, right? -Jeff here, bloggy bloggy

                            W 1 Reply Last reply
                            0
                            • E eggie5

                              What about different CPUs? /\ |_ E X E GG

                              D Offline
                              D Offline
                              Dave Kreskowiak
                              wrote on last edited by
                              #14

                              The .NET Framework and Java are both PLATFORM INDEPENDANT. An Integer in either one is the same size on any CPU. Now, for assembly language, C/C++, or any other language that is tightly tied to the processor, that's a very different story... RageInTheMachine9532

                              E 1 Reply Last reply
                              0
                              • D Dave Kreskowiak

                                The .NET Framework and Java are both PLATFORM INDEPENDANT. An Integer in either one is the same size on any CPU. Now, for assembly language, C/C++, or any other language that is tightly tied to the processor, that's a very different story... RageInTheMachine9532

                                E Offline
                                E Offline
                                eggie5
                                wrote on last edited by
                                #15

                                Thank you for your explination. I understand now. /\ |_ E X E GG

                                1 Reply Last reply
                                0
                                • E eggie5

                                  Litvin, Maria. Be Prepared for the AP Computer Science Exam in Java. Andover, MA: 2003.

                                  14. Which of the following statements about Java's platform independence are true?

                                  I. The number of bytes used by an int variable is the same on any computer.

                                  II. Java source code is complied into bytecodes, which may then be run on any computer with the Java Virtual Machine installed.

                                  III. Overflow in arithmetic operations occurs at the same values regardless of the platform on which the Java program is running.

                                  (A) I only
                                  (B) II only
                                  (C) I and II
                                  (D) II and III
                                  (E) I, II, and III

                                  /\ |_ E X E GG

                                  M Offline
                                  M Offline
                                  Maxwell Chen
                                  wrote on last edited by
                                  #16

                                  :eek: Primitive Types[^] The values represented by these types are specified in Table 3-1. The representation shown is used on all platforms and is independent of the native platform architecture. int 32-bit, signed, two's complement All of the signed integer types in Java use a two's complement representation. Two's complement is a binary encoding for integers, which has the following properties: The leftmost bit is the sign bit. If the sign bit is 1, the number is negative. Positive numbers have the usual binary representation. Negating a number involves complementing all of the bits in the number and then adding 1 to the result. The most negative value does not have a positive equivalent. ........ Maxwell Chen

                                  1 Reply Last reply
                                  0
                                  • E eggie5

                                    This book says it's true. That's a bunch of crap... Oh, well, I guess I have to go with it. Look at what they're teaching kids these days! /\ |_ E X E GG

                                    T Offline
                                    T Offline
                                    Terry ONolley
                                    wrote on last edited by
                                    #17

                                    As far as Java is concerned, it is true. The VM for each OS has the job of deciding how big to make the int, but as far as Java programming is concerned, an int is an int. Think about it - you don't need to use a bunch of pre-processors in java to determine how to typedef ints.


                                    Glano perictu com sahni delorin!

                                    1 Reply Last reply
                                    0
                                    • E eggie5

                                      The number of bytes used by an int variable is the same on any computer. /\ |_ E X E GG

                                      M Offline
                                      M Offline
                                      Michael Dunn
                                      wrote on last edited by
                                      #18

                                      In C/C++, the size of an int is compiler-dependent. It's 16 bits in Win16, 32 bits in Win32/Win64, and so on. I believe the C++ spec says it has to be at least 16 bits. In other languages they define the size of an int explicitly. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- "Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"   -- Rico Mariani, CLR perf guy

                                      1 Reply Last reply
                                      0
                                      • J Jeff Varszegi

                                        You're not the first person to say that, but think of it this way: it would be hard to make a claim like "write once, run anywhere" if the code could behave differently on different platforms, right? -Jeff here, bloggy bloggy

                                        W Offline
                                        W Offline
                                        Wouter Dhondt
                                        wrote on last edited by
                                        #19

                                        Well, they should have dropped the int for clarity and used DWORD. ----------------------- New and improved: kwakkelflap.com My second CP article: MAP files[^] "Hey, Eddie, can I pour you a beer?" "A little early, isn't it, Richy?" "For a beer?" "No, for stupid questions."

                                        1 Reply Last reply
                                        0
                                        • E eggie5

                                          The number of bytes used by an int variable is the same on any computer. /\ |_ E X E GG

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

                                          I see you later qualify it for ints in Java. In that case all use 4 bytes. Elaine :rose: The tigress is here :-D

                                          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