Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know with changing the variable type, the speed of the program change. I want to understand the other effects of this change in the software performance.

I want to know if we use a floating point variable instead of fixed point variable,the amount of memory consumption and speed of program, what will change?

share|improve this question
2  
Possible duplicate: stackoverflow.com/questions/417568/float-vs-double-performance/… I was gonna write something similar but the given answer answers your question perfectly. I'm guessing for newer platforms the same answer still applies. –  Steven Jeuris Apr 18 '11 at 11:04
    
As a sidenote, I once worked on a project for a device which didn't have a FPU, neither float or double were an option. Something to keep in mind if you ever find yourself in that situation. –  Steven Jeuris Apr 18 '11 at 11:16
add comment

2 Answers

This is like trying to find your lost ocean liner, using a magnifying glass to look at the dock.

If you're early in a project, the key to performance is simplicity, particularly of data structure design. Don't put in anything fancy or complicated before you've demonstrated a need for it.

Once you're into the project, performance problems creep in. They're just like bugs except less obvious. However, they are actually more easy to find than bugs. I depend on the random-pausing method.

Maybe you will find at some point that floating-point is causing a problem, maybe not. When you do, that is the time to worry about it, not before. Good luck.

share|improve this answer
    
+1 for best analogy ever. Premature optimization is the root of all evil. –  Rein Henrichs Apr 18 '11 at 16:19
    
@Rein: I always liked "Getting a haircut to lose weight". –  Mike Dunlavey Apr 19 '11 at 1:32
    
You are the root of all awesome analogies. I, on the other hand, suck at analogies. I'm worse at analogies than I am at most other things that I suck at. –  Rein Henrichs Apr 19 '11 at 4:19
    
@Rein: Oh, you're just being modest :) I didn't originate the haircut analogy. It was a new user on SO in '09 who I was never able to find again. –  Mike Dunlavey Apr 19 '11 at 11:59
add comment

If you spend time thinking about this while writing your code, there's an excellent chance you'll introduce some infelicity. Even if it isn't a bug, it could easily cost you far more space and performance than changing a variable type will.

Moreover, floating point and integral types do different things (otherwise we wouldn't have both of them). There are algorithms that work better on one or the other. Any change to a less efficient algorithm, or one awkwardly coded, is going to cost you a lot more than integer vs. floating.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.