What is the minimum value of a floating point variable on an ARMmite?
I have an equation that Sums some Variables and compares the Sum with a
previously stored value to detect errors. The result must be +/- 1 bit,
but these are floating point values, so 1 bit is quite small.
Minimum floating point value
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Minimum floating point value
--- In ARMexpress@yahoogroups.com, "Dan Lee" <danlee_58@...> wrote:
>
>
> What is the minimum value of a floating point variable on an ARMmite?
>
> I have an equation that Sums some Variables and compares the Sum with a
> previously stored value to detect errors. The result must be +/- 1 bit,
> but these are floating point values, so 1 bit is quite small.
>
This is really a C question, but a quick Google found this
http://www.cplusplus.com/reference/clibrary/cfloat/
The answer it gives is 1 E-37
This now also applies to the BASIC compiler. When comparing 2 numbers, the relative difference between the numbers is limited by size of the mantissa which is 23 bits. So if 2 numbers have the same exponent, the min difference is about 1/100000000, or 100 million.
>
>
> What is the minimum value of a floating point variable on an ARMmite?
>
> I have an equation that Sums some Variables and compares the Sum with a
> previously stored value to detect errors. The result must be +/- 1 bit,
> but these are floating point values, so 1 bit is quite small.
>
This is really a C question, but a quick Google found this
http://www.cplusplus.com/reference/clibrary/cfloat/
The answer it gives is 1 E-37
This now also applies to the BASIC compiler. When comparing 2 numbers, the relative difference between the numbers is limited by size of the mantissa which is 23 bits. So if 2 numbers have the same exponent, the min difference is about 1/100000000, or 100 million.
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Minimum floating point value
> I have defined a floating point variable 'ONE_BIT' = 0.0024 E-6. This
> is the limit that I will check the Checksum for an error.
>
Using floating point to do checksums WILL generate grief. If you've
ever seen an answer on your calculator 3.999999999 when you expected
4, is the reason. Floating point will generate results that are not
the exact answer as the exact answer can't be represented as a binary
number with a binary exponent.
It would be better to do a type cast to (int) and then do the checksum.
> is the limit that I will check the Checksum for an error.
>
Using floating point to do checksums WILL generate grief. If you've
ever seen an answer on your calculator 3.999999999 when you expected
4, is the reason. Floating point will generate results that are not
the exact answer as the exact answer can't be represented as a binary
number with a binary exponent.
It would be better to do a type cast to (int) and then do the checksum.
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Minimum floating point value
In a message dated 1/25/2009 9:46:13 PM Central Standard Time,
bruce@... writes:
--- In _ARMexpress@yahoogroARMexpr_ (mailto:ARMexpress@yahoogroups.com) ,
"Dan Lee" <danlee_58@.da> wrote:
>
>
> What is the minimum value of a floating point variable on an ARMmite?
>
> I have an equation that Sums some Variables and compares the Sum with a
> previously stored value to detect errors. The result must be +/- 1 bit,
> but these are floating point values, so 1 bit is quite small.
>
This is really a C question, but a quick Google found this
_http://www.cpluspluhttp://www.cplushttp://wwhttp://_
(http://www.cplusplus.com/reference/clibrary/cfloat/)
The answer it gives is 1 E-37
You have to be very careful in comparing or subtracting floating point
numbers. The answer you seek is more likely dependent on the range of your
input
values, even though you can express a float as small as 1 E-37. That's
because you can't compare or subtract two numbers that together extend outside
the
range of the mantissa, whatever that is in the ARMmite version of C. Well,
you can, but you'll either get an out-of-range error, or it will give you the
wrong answer.
The table Bruce referred to above has an entry titled, "Difference between 1
and the least value greater than 1 that is representable," that gives 1 E-9
for a double precision number. I don't know much about C, but I think you
will be OK if you keep the difference between your numbers less than that
value.
Don W.
**************From Wall Street to Main Street and everywhere in between, stay
up-to-date with the latest news. (http://aol.com?ncid=emlcntaolcom00000023)
[Non-text portions of this message have been removed]
bruce@... writes:
--- In _ARMexpress@yahoogroARMexpr_ (mailto:ARMexpress@yahoogroups.com) ,
"Dan Lee" <danlee_58@.da> wrote:
>
>
> What is the minimum value of a floating point variable on an ARMmite?
>
> I have an equation that Sums some Variables and compares the Sum with a
> previously stored value to detect errors. The result must be +/- 1 bit,
> but these are floating point values, so 1 bit is quite small.
>
This is really a C question, but a quick Google found this
_http://www.cpluspluhttp://www.cplushttp://wwhttp://_
(http://www.cplusplus.com/reference/clibrary/cfloat/)
The answer it gives is 1 E-37
You have to be very careful in comparing or subtracting floating point
numbers. The answer you seek is more likely dependent on the range of your
input
values, even though you can express a float as small as 1 E-37. That's
because you can't compare or subtract two numbers that together extend outside
the
range of the mantissa, whatever that is in the ARMmite version of C. Well,
you can, but you'll either get an out-of-range error, or it will give you the
wrong answer.
The table Bruce referred to above has an entry titled, "Difference between 1
and the least value greater than 1 that is representable," that gives 1 E-9
for a double precision number. I don't know much about C, but I think you
will be OK if you keep the difference between your numbers less than that
value.
Don W.
**************From Wall Street to Main Street and everywhere in between, stay
up-to-date with the latest news. (http://aol.com?ncid=emlcntaolcom00000023)
[Non-text portions of this message have been removed]