Thread: Equal compare

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    Equal compare

    Hello everyone,


    I want to confirm that on a 32-bit machine,

    1. compare the value of two byte to see whether they are equal or not;
    2. compare the value of two integer (4-byte) to see whether they are equal or not.

    (1) and (2) should have the same performance, right? I am using x86 32bit Windows machine to develop native unmanaged C++ application.


    thanks in advance,
    George

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    That's true most of the time at least (always true for regular ints and longs).

    The only time it isn't true is when you have a pointer to int say, and that pointer isn't on a 4-byte boundary. On an X86, you just slow down a bit. On other machines, you get a bus error (see another recent post).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  2. compare if 2 string types are equal
    By sujeet1 in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2007, 06:37 PM
  3. compare strings not working
    By gtriarhos in forum C Programming
    Replies: 7
    Last Post: 09-29-2005, 12:51 PM
  4. Reading a file written by VB
    By nemaroller in forum C++ Programming
    Replies: 8
    Last Post: 07-12-2002, 11:17 PM
  5. how can 0.00665 not equal 0.00665??!!
    By Susan in forum C++ Programming
    Replies: 10
    Last Post: 02-10-2002, 02:33 AM