Click here to Skip to main content
15,851,711 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Is it worth to change all the int and char types in my C program to unsigned, by the time I use only physical numbers?

Is this change will make my programm faster?

1 solution

No, it won't make your program any faster.
The CPU doesn't make any distinction between signed and unsigned integers - they are all treated as 16, 32, or 64 bit numbers (depending on environment) in exactly the same way.

If you want to speed you program up, then start by timing it to find out where it's slowest, and focus your attention on that! Slow code is more often caused because of inefficient algorithms, rather than type of integer used. :laugh:
Share this answer
[no name] 29-Nov-14 10:08am    
is there any program that can make such calculations?
OriginalGriff 29-Nov-14 10:24am    
Not really - because it isn't a "Line-but-line" thing: you need to start at a high level and decide which program "chunks" to check first - and then focus in on them. And don't forget, adding timing checks will slow your code down!

There are profiling tools, but they generally don't help much because they don't know what it important and what isn't in you application - so they tend to generate a lot of information and make it difficult to see what you need to see.
[no name] 29-Nov-14 10:36am    
ok I understand. Do you want to suggest me such programs just for the record?
OriginalGriff 29-Nov-14 10:52am    
I haven't played with C profilers for so long that I can;t suggest anything - I can't even remember the ones I used (just that they were all universally useless for one reason or another, and finding that out always took at least twice as long as doing it manually!)
If you want to look, then Google should find you some.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900