View previous topic :: View next topic |
Author |
Message |
gastaoc
Joined: 09 Nov 2008 Posts: 4
|
Fixed Point Decimal |
Posted: Tue Aug 28, 2012 6:40 pm |
|
|
How is possible to declare a fixed point decimal ? When a try to use a simple int16 _fixed(2) money; compiling with 4.135 = *** Error 48 "extreme_potencia_lcd.c" Line 100(19,24): Expecting a ( |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Aug 28, 2012 6:43 pm |
|
|
formatted fprint() is usually the tool:
BUT.......
show your code - especially what you are trying to compile
and what you want to achieve |
|
|
gastaoc
Joined: 09 Nov 2008 Posts: 4
|
|
Posted: Tue Aug 28, 2012 7:08 pm |
|
|
After reading about the advantages of using variables of type fixed decimal point over using variables of type float tried to declare as an example: int16 _fixed (2) money;
Code: |
#include <16F873A.h>
#device adc=8
#fuses hs
#fuses nowdt
#fuses nolvp
#fuses noput
#use delay(clock=20000000)
void main(void)
{
int16 one;
int16 two;
int16 _fixed(2) money;
money=1.23;
money+=3;
}
|
When I compile the program:
Clean: Deleting intermediary and output files.
Clean: Deleted file "extreme_potencia_7seg.ESYM".
Clean Warning: File "C:\Next Controladores\Next Extreme\software\extreme_potencia_7seg.o" doesn't exist.
Clean: Deleted file "extreme_potencia_7seg.ERR".
Clean: Done.
Executing: "C:\Arquivos de programas\PICC\Ccsc.exe" +FM "extreme_potencia_7seg.c" +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 48 "extreme_potencia_7seg.c" Line 27(19,24): Expecting a (
*** Error 48 "extreme_potencia_7seg.c" Line 29(3,8): Expecting a (
*** Error 43 "extreme_potencia_7seg.c" Line 29(9,13): Expecting a declaration
*** Error 43 "extreme_potencia_7seg.c" Line 29(13,14): Expecting a declaration
*** Error 48 "extreme_potencia_7seg.c" Line 30(3,8): Expecting a (
*** Error 43 "extreme_potencia_7seg.c" Line 30(10,11): Expecting a declaration
*** Error 43 "extreme_potencia_7seg.c" Line 30(11,12): Expecting a declaration
*** Error 43 "extreme_potencia_7seg.c" Line 31(3,4): Expecting a declaration
8 Errors, 0 Warnings.
Build Failed.
Halting build on first failure as requested.
BUILD FAILED: Tue Aug 28 22:08:37 2012 |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Tue Aug 28, 2012 11:21 pm |
|
|
I'm not using this new-fashioned stuff, but it seems like _fixed(n) has been broken in CCS V4.133 or V4.134. Ask CCS. |
|
|
gastaoc
Joined: 09 Nov 2008 Posts: 4
|
|
Posted: Wed Aug 29, 2012 6:27 am |
|
|
Thank you for your attention.
The problem is that I am using the demo version and I have no right to support. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Wed Aug 29, 2012 6:34 am |
|
|
You can still report the issue to CCS. Given they want to sell you the compiler, they should still react.
Best Wishes |
|
|
gastaoc
Joined: 09 Nov 2008 Posts: 4
|
|
Posted: Wed Aug 29, 2012 7:02 am |
|
|
Thank you.
I did the same test on version 4.130 and it worked.
Now it's wait if this type of data no longer exists or is a version 4.135 bug and will be fixed.
Best Regards. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Aug 29, 2012 7:56 am |
|
|
Quote: | How is possible to declare a fixed point decimal ? When a try to use a simple int16 _fixed(2) money; compiling with 4.135 = *** Error 48 "extreme_potencia_lcd.c" Line 100(19,24): Expecting a ( |
Why not work in integer cents (or UK pence) when calculating with money?
Mike |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Aug 29, 2012 9:26 am |
|
|
as wisely mentioned above- if int16 money is unitary cents , then
printf("%5.2w ",money);
will format as you wish, since you are not going to be able to use fixed point integers for calculation anyway, are you ?? |
|
|
|