float comparison confusion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chrolson@gmail.com

    #1

    float comparison confusion

    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?

  • skip@pobox.com

    #2
    Re: float comparison confusion


    chrolsonWhy is cmp returning -1 instead of returning positive integer?

    Last time I checked 20.1 was less than 20.9.

    Skip

    Comment

    • Ben Finney

      #3
      Re: float comparison confusion

      "chrolson@gmail .com" <chrolson@gmail .comwrites:
      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

      Comment

      Working...