View previous topic :: View next topic |
Author |
Message |
kkatesuda
Joined: 09 Sep 2006 Posts: 8
|
Question for Float Variable |
Posted: Mon Sep 11, 2006 8:25 am |
|
|
I try to use Float to define 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
|
|
Posted: Mon Sep 11, 2006 9:20 am |
|
|
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
|
|
Posted: Mon Sep 11, 2006 12:43 pm |
|
|
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
|
|
Posted: Mon Sep 11, 2006 3:16 pm |
|
|
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
|
|
Posted: Mon Sep 11, 2006 6:40 pm |
|
|
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. |
|
|
|