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

Question for Float Variable

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



Joined: 09 Sep 2006
Posts: 8

View user's profile Send private message

Question for Float Variable
PostPosted: Mon Sep 11, 2006 8:25 am     Reply with quote

I try to use Float to define my Variable

Code:
 Float  my_variable


Please give me more infomation for the data lenght of Float

I try to use Float for my variable that have value between 0 - 1 but sensiviliey of this Value at 0.0000001 I can't multiply it because after I process this function and keep it in my_variable i must use arctan function for calulate in next step.

Please advice me how to use this variable.

Katesuda
Ttelmah
Guest







PostPosted: Mon Sep 11, 2006 9:20 am     Reply with quote

Look at the file 'float.h'. This is a standard C include file (standard in any C offering a float library), defining the data sizes.
You will not get the sort of resolution you are talking about. The float, has a 'core' resolution 1 in (2^24)-1. It 'one normalises' the mantissa, and then stores 23bits, leaving out the leading '1'. It therefore has a basic accuracy of just over 6 digits.

Best Wishes
kkatesuda



Joined: 09 Sep 2006
Posts: 8

View user's profile Send private message

PostPosted: Mon Sep 11, 2006 12:43 pm     Reply with quote

Please give me more. How i use float.h just include? plase give me some example.

Thank you very much.
Katesuda
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Sep 11, 2006 3:16 pm     Reply with quote

Calculating to one part in ten million is going to be tough. CCS 24 bit floats won't work. Neither will a scaled double integer. You are going to have to roll your own data type and math functions. I use 24 bit integers to measure ship hulls but all I do in the PIC is add and subtract. Anything more complex gets handed off to a PC. 0.15mm x 2^24 = 2.5km, good enough to measure the thickness of the steel or the length of anything afloat.
What is the application that requires this extreem precision? Maybe we can find a work-around for you.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon Sep 11, 2006 6:40 pm     Reply with quote

I posted some CORDIC routines in the code library it may give you the arctan precision you want without floating point. It only uses addition and subtraction and shifting so it could be modified to doubleprecision say 64 bits.
There are sqrt (x^2+y^2) polar to cartesion conversions etc. there as well.
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