|
|
View previous topic :: View next topic |
Author |
Message |
Bordi Guest
|
Float Workaround |
Posted: Fri May 20, 2005 6:37 am |
|
|
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
|
|
Posted: Fri May 20, 2005 7:36 am |
|
|
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
|
|
Posted: Fri May 20, 2005 7:49 am |
|
|
yeah you're right i'm so stupid man the solution was simple!!!
thx |
|
|
|
|
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
|