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 CCS Technical Support

Float Workaround

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







Float Workaround
PostPosted: Fri May 20, 2005 6:37 am     Reply with quote

Code:

   volume+=5;
   printf(LCD_PUTC, "%lu",volume/10);
   vol=volume-((volume/10)*10);
   printf(LCD_PUTC, ".%lu",vol);
   lcd_putc(" ml     ");


Solution for the inexact floats results, less space and more precision.

but

Code:


   taxa= 3600000000 / (655 * t1) ;   // Tax calc timer*0.065536s
   printf(LCD_PUTC, "%lu",taxa/100);
   tx2=taxa-((taxa/100)*100);
   printf(LCD_PUTC, ".%1lu",tx2);
   lcd_putc("ml/h      ");



i need to calculate a tax of mL per hour so i get the secs of one hour and divide by the time it takes to flow 1mL in the sistem

the tx2 calc is to take just the decimal part of the number !

so u can see that i've scaled the constant 0.065536 but i cant use the last "36" because i need to have this 2 zeros of span to get the right scalling result, it was better to have thesee digits, but here we are the main problem.. finally.... the 3600000000 is in the max range of numbers in ccs, one more zero and it gets out of 32bits int.... ow can i solve that???


Using PIC16F870, compilers v3.19

Reguards
Fernando.
Guest
Guest







PostPosted: Fri May 20, 2005 7:36 am     Reply with quote

I don't really understand your problem but if you use:
Code:
taxa= (3600000000 / 655) / t1 ;

the compiler should do 3600000000 / 655 at compile time giving you a smaller number to divide by t1.

Sherpa Doug
Bordi
Guest







PostPosted: Fri May 20, 2005 7:49 am     Reply with quote

yeah you're right i'm so stupid man the solution was simple!!!
thx
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