Uploaded image for project: 'Swift'
  1. Swift
  2. SR-106

description returns a rounded value of Double

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Standard Library
    • Labels:
      None
    • Environment:
      >lldb -version
      lldb-340.4.110.1
      

      Description

      It looks like the string representation of a Double returned by description is less precise than the Double itself. Look at the example below.

      // swift
              let point = CGPoint(x: 350.00000000000017, y: 0)
              let value: CGFloat = 350.0
              
              if point.x == value { // correctly, will never be reached
                  print("")
              }
              print(point.x) // prints 350.0
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tbkka Tim Kientzle
              Reporter:
              wczekalski Wojtek Czekalski
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: