Re: Float comparison



CBFalconer <cbfalconer@xxxxxxxxx> writes:
[...]
True, but we are talking about FP representation (and int
representation), which have other limitations, including maximum
and minimum values. ints don't have a range associated with each
value, the adjacent integer value is always available. Reals don't
have an adjacent value, but rationals do (they are countable). The
FP system is built on rationals, but cannot express the adjacent
rational. Neither the integer nor the FP system can handle the
infinities that exist in arithmetic.

Yes, rationals are countable, but no, they do not have adjacent
values. Given any two rational numbers x and y, the rational number
(x+y)/2 is between them and distinct from both of them. (I'm
referring to mathematical rational numbers here, not to any C
representation of them.)

However floating-point types do have adjacent values. For example,
1.0 and 1.0+DBL_EPSILON are adjacent values of type double; there are
no double values between them.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: Possreps and numeric types
    ... digit integers because it didn't have enough memory. ... A billion digit integer doesn't make a whit of difference to what I wrote earlier: One still has a maximum representable integer, and a maximum representable integer defines a minimum range for the representation of each value. ... representation for all three and for an infinite number of other rationals. ... sqrtis an approximation; sqrtis not. ...
    (comp.databases.theory)
  • Re: Possreps and numeric types
    ... We certainly have resource limits in our finite computers. ... We cannot represent the rationals in finite computers. ... defines a minimum range for the representation of each value. ...
    (comp.databases.theory)
  • Re: Possreps and numeric types
    ... representation of numbers. ... case of the rationals and the integers. ... This starts to sound like possreps to ... string as a number. ...
    (comp.databases.theory)
  • Re: Possreps and numeric types
    ... we don't have the resources. ... it is precise and exact. ... Precise for integers but rationals are not integers. ... defines a minimum range for the representation of each value. ...
    (comp.databases.theory)
  • Re: infinity
    ... each element has two successors. ... > way, but as a symbolic representation of quantity, they're two ... > Perhaps rationals should be built from the set of primes in some ... For naturals, successorship is unique and creates a sequencial order ...
    (sci.math)