I am programming C on linux, and which is faster in the following conditions?
1.processing 32bit integers on 32bit hardware and 64bit hardware
2.processing 64bit integers on 32bit hardware and 64bit hardware
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You should tell on what exact hardware, and what kind of processing.
And more importantly, you should benchmark your application, taking into account that premature optimization is evil.
Standard C99 provides you with the
<stdint.h>with thefastint_ttype (and others, e.G.intptr_torint32_t…); there is also a<inttypes.h>standard header.I believe you should not bother at first. If you know that some integer data type is very crucial to your application, you might use your own typedef, eg.
Then you develop your application using appropriately
myimportantint_t, and benchmark it. You can then easily change thattypedef. (So changing the size of your important integers would be easy, just changing that typedef and perhaps defining aMYIMPORTANT_MAXpreprocessor constant, etc.).See this question very related to yours.
I believe you should not care that much.
Of course, 64 bits arithmetic on many 32 bits processors is more costly than 32 bits arithmetic.