Hi All, Anyone know what the accuracy and/or precision of floating point math is on the DSP56F80x processors when using CodeWarrior? I have been having a lot of problems getting accurate results from "simple math" . I get a lot of values that look like this, 1.029999 and .4900002, when they should be 1.030000 and .4900000. A typical formula used may be as shown below. fFoffTime -= (1.0f / fOnOffDpPow); Where all vars are floats and fFoffTime is being incremented or decremented by 0.01. When fOnOffDpPow = 100.0 the debugger show it's hex value as 0x42C80001 where all the float-to-hex converters I have tried show the value as 0x42C80000. Will differences like that add up to the errors I am seeing? If I force fOnOffDpPow to be 0x42C80000 in the debugger I still have problems. Is this just the way it is or are there settings or programming methods that can improve floating point calculations. Help Appreciated. Pete |
|
Floating Point Precision and Accuracy, 56F80x
Started by ●August 27, 2003
Reply by ●August 27, 20032003-08-27
Pete, A floating point number is 32-bits, made up of 23 bits for the mantissa, 8 bits for exp and 1 sign bit. It will also round up to the nearest even value. I don't know if this is exactly what you are looking for but this is the information that I have. - Irene --- In , "Pete Becher" <pbecher@d...> wrote: > Hi All, > > Anyone know what the accuracy and/or precision of floating point math > is on the DSP56F80x processors when using CodeWarrior? I have been > having a lot of problems getting accurate results from "simple math" . > > I get a lot of values that look like this, 1.029999 and .4900002, > when they should be 1.030000 and .4900000. A typical formula used > may be as shown below. > > fFoffTime -= (1.0f / fOnOffDpPow); > > Where all vars are floats and fFoffTime is being incremented or > decremented by 0.01. When fOnOffDpPow = 100.0 the debugger show it's > hex value as 0x42C80001 where all the float-to-hex converters I have > tried show the value as 0x42C80000. Will differences like that add > up to the errors I am seeing? If I force fOnOffDpPow to be > 0x42C80000 in the debugger I still have problems. > > Is this just the way it is or are there settings or programming > methods that can improve floating point calculations. > > Help Appreciated. > Pete |
Reply by ●August 27, 20032003-08-27
Pete, A floating point number is 32-bits, made up of 23 bits for the mantissa, 8 bits for exp and 1 sign bit. It will also round up to the nearest even value. I don't know if this is exactly what you are looking for but this is the information that I have. - Irene --- In , "Pete Becher" <pbecher@d...> wrote: > Hi All, > > Anyone know what the accuracy and/or precision of floating point math > is on the DSP56F80x processors when using CodeWarrior? I have been > having a lot of problems getting accurate results from "simple math" . > > I get a lot of values that look like this, 1.029999 and .4900002, > when they should be 1.030000 and .4900000. A typical formula used > may be as shown below. > > fFoffTime -= (1.0f / fOnOffDpPow); > > Where all vars are floats and fFoffTime is being incremented or > decremented by 0.01. When fOnOffDpPow = 100.0 the debugger show it's > hex value as 0x42C80001 where all the float-to-hex converters I have > tried show the value as 0x42C80000. Will differences like that add > up to the errors I am seeing? If I force fOnOffDpPow to be > 0x42C80000 in the debugger I still have problems. > > Is this just the way it is or are there settings or programming > methods that can improve floating point calculations. > > Help Appreciated. > Pete |