variable type

M

Mike Hodkin

Just out of curiosity, if a program uses a FLOAT type with a FOR loop
counter instead of an INT type, would this cause any slow-down in
performance or other problem (other than excess memory allocation for the
variable)?

eg.

float count; // instead of int count

for (count =1; count <=4, count++)

{

//code here

}
 
M

Mike Wahler

Mike Hodkin said:
Just out of curiosity, if a program uses a FLOAT type with a FOR loop
counter instead of an INT type, would this cause any slow-down in
performance

Maybe, maybe not. Only way to know is to measure.
or other problem

If you're using other than integer values, yes, precision
could be a problem.
(other than excess memory allocation for the
variable)?

You can't assume that a 'float' is larger than an 'int'.
eg.

float count; // instead of int count

for (count =1; count <=4, count++)

{

//code here

}

Why do you want to use type 'float'?

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,150
Messages
2,570,853
Members
47,394
Latest member
Olekdev

Latest Threads

Top