float comparison confusion

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Jan 19 20:37:06 EST 2007


"chrolson at gmail.com" <chrolson at gmail.com> writes:

> Type "help", "copyright", "credits" or "license" for more information.
> >>> cmp(20.10, 20.9)
> -1
>
> Why is cmp returning -1 instead of returning positive integer?

    >>> 20.10 < 20.9
    True
    >>> 20.1 < 20.9
    True
    >>> 20.10 == 20.1
    True

What leads you to expect otherwise?

-- 
 \      "A society that will trade a little liberty for a little order |
  `\    will lose both, and deserve neither."  -- Thomas Jefferson, in |
_o__)                                              a letter to Madison |
Ben Finney




More information about the Python-list mailing list