CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

use of float

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
davt



Joined: 07 Oct 2003
Posts: 66
Location: England

View user's profile Send private message

use of float
PostPosted: Thu Mar 31, 2005 4:17 am     Reply with quote

Hi everybody

I am designing a long delay timer and I need a 32 bit variable to count a large number of "ticks" , can I just declare a float variable and use it to count the "ticks" .
Thanks Very Happy

Dave
valemike
Guest







PostPosted: Thu Mar 31, 2005 7:41 am     Reply with quote

I don't know what the range of CCS's floats are, but even those are finite.

How many ticks, or Seconds, do you want to elapse? For example, if I wanted to count, say, 30 minutes, I would do the following.

Looking at CCS's example program ex_stwt1.c, there is a SECONDS timer. So if I wanted to get 30 minutes out of it, then I would need 60 x 30 = 1800 seconds. See how 1800 easily fits inside an "unsigned long" which can go up to 65535 (thus 65535 / 60 = 1092 minutes).

That is how i would go about achieving a long timer, rather than using a float.
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 31, 2005 7:46 am     Reply with quote

So, why not use int32?
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

PostPosted: Thu Mar 31, 2005 10:58 am     Reply with quote

Darren Rook wrote:
So, why not use int32?


good question.
_________________
-Matt
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group