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

Fixed Point Decimal

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



Joined: 09 Nov 2008
Posts: 4

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

Fixed Point Decimal
PostPosted: Tue Aug 28, 2012 6:40 pm     Reply with 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 (
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Aug 28, 2012 6:43 pm     Reply with quote

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

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

PostPosted: Tue Aug 28, 2012 7:08 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 28, 2012 11:21 pm     Reply with quote

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

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

PostPosted: Wed Aug 29, 2012 6:27 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 29, 2012 6:34 am     Reply with quote

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

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

PostPosted: Wed Aug 29, 2012 7:02 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 29, 2012 7:56 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Wed Aug 29, 2012 9:26 am     Reply with quote

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 ??
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