BOOL or BYTE

This is a discussion on BOOL or BYTE within the C++ Programming forums, part of the General Programming Boards category; which is faster: BOOL num; if(num==1).... or BYTE num; if(num & 0x80)........

  1. #1
    Unregistered
    Guest

    BOOL or BYTE

    which is faster:

    BOOL num;

    if(num==1)....

    or

    BYTE num;

    if(num & 0x80).....

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    i would guess byte would be faster, although you're talking about a miniscule difference. if you're concerned over speed try using ints.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    Just looked them up. BYTE is defined as an unsigned char, BOOL is defined as an int (strangely enough) so I would guess that BYTE is faster to mess with.

  4. #4
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    oh. in that case, i side with BOOL. integers are manipulated faster than other smaller data pieces.

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    I wouldnt assume that using a BYTE would automatically help the processor....A BOOL is a typedef for a DWORD which is a typedef for a 32bit value.......as most processors used on PCs use 32Bit registers, using memory less than 32bit might even create more work....I'm not totally sure on this, but from reading I've noticed that lots of coders stick to 32Bit when optimising code...

    Anyway.....Is this part of the code so critical that losing 1 or 2 clock cycles would have a noticable effect?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21