Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:43:12+00:00 2026-06-04T05:43:12+00:00

I am programming a game and want to represent a board using an array.

  • 0

I am programming a game and want to represent a board using an array. I am looking for efficiency since I am going to do many iterations. In this case, both an int array or a char array seem convenient for the board representation. Is there any difference in terms of efficiency when doing operations in an int array and a char array?

I suspect that since every element of the char array has size of 1 byte it may be slower because of a different representation in memory (consider a modern computer which has at least 32 bits for int representation)… Am I right?

Thanks in advance.

EDIT: I am going to generate game trees, that’s why efficiency is so important and small differences in time consumption can make a huge difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:43:14+00:00Added an answer on June 4, 2026 at 5:43 am

    For which CPU/s?

    Some CPUs can’t directly access anything smaller than “something”, and the compiler needs to generate a “load, shift and mask” sequence of instructions to access individual bytes. Using int should win for this case.

    Some CPUs can access bytes without problems. In this case (if enough data is involved that it matters) the problem is likely to be cache size and/or memory bandwidth; and (at least for 80×86) I’d expect char would win simply because more data is packed into each cache line.

    For which algorithm/s?

    If you can throw SIMD at it, char is likely to win. For example, with 128-bit SIMD you can process 16 bytes per instruction or 4 (32-bit) integers per instruction and char might be 4 times faster because of this alone.

    The best advice would be to use something like:

    #ifdef USE_INT
        typedef int thingy
    #else
        typedef unsigned char thingy
    #endif
    

    Then you can profile it and change it whenever you like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm programming an Android game using AndEngine. I want to create a circle which
I have started looking into iPhone game programming. I want to build a game
With reference to this programming game I am currently building. I am using WPF
I am programming a game using Visual C++ 2008 Express and the Ogre3D sdk.
I'm programming this game in OpenGL, mostly working inside an single EAGLView (I'm not
I am programming a game using C#, thus, I am very concerned about performance.
So it has been a while since I have done any game programming in
I want to create a browser based 3D game using LWJGL with the Java
Hello everyone I am interested in Java game programming, but I want to do
In the name of efficiency in game programming, some programmers do not trust several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.