View previous topic :: View next topic |
Author |
Message |
Johann17943
Joined: 11 Dec 2010 Posts: 11 Location: Germany
|
signed float |
Posted: Mon May 12, 2014 2:53 pm |
|
|
Sorry, but I have not found something in the Forum, but perhaps somebody can help very quickliy
I Need to define a signed float data type (for example -1.0769) and don't know how (signed float will not work) Compiler Version 4.141
Thanks.
Johann |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 12, 2014 3:11 pm |
|
|
Download the CCS manual. Go to page 37. It says a 'float' can take
values in this range: -1.5 x 1045 to 3.4 x 1038
So yes, a 'float' is inherently capable of holding a negative number.
Example:
Code: |
void main()
{
float temp = -5.321;
} |
|
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon May 12, 2014 3:13 pm |
|
|
Hi,
A 'float' data type in 'C' is inherently signed, so you need to do nothing more than
Code: |
float MyVariable = -1.0769;
|
Frankly, it's a strange question as mostly you encounter people that want an 'unsigned' version of the float variable for things that will never be negative, ie. the result of a square root operation.
John |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon May 12, 2014 3:17 pm |
|
|
this is right up there with the special CCS vartype
signed int1
|
|
|
Johann17943
Joined: 11 Dec 2010 Posts: 11 Location: Germany
|
|
Posted: Tue May 13, 2014 8:44 am |
|
|
Hi!
Thanks a lot!
I have a quite old printed manual, but I'm using the Help-button from the Compiler. There is no range given for the float32.
I think, I should update my Compiler :-)
Thanks again!
Regards,
Johann |
|
|
|