-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-443] CGFloats parsed from string do not round trip #4181
Comments
This isn't testing CGFloat string parsing at all. Ultimately, it's testing |
Ah got it, thanks. Presumably it would be better to have a single path? |
Probably, although unless we want to introduce something like I'm actually not entirely sure offhand why |
"skimming the current Where do you see this? The code I'm looking at uses strtod for double parsing. |
Oh. I was looking at CFScanner, not Scanner.swift. Yes, that code should definitely be using either Double.init(_:String) or it should call strtod from the C library. |
This has been fixed on macOS now at least since 5.1.3 on 10.14 and is fixed in swift-corelibs-foundation with PR #2820 $ cat jiras/sr-443.swift
import Foundation
let point1 = NSPointFromString("\{1.0, 1.2234234234}")
let point2 = NSPoint(x: CGFloat(1.0), y: CGFloat(1.2234234234))
print("\(point1) \(point2) \(point1 == point2)")
print("\nTesting scanDouble")
let input = "1.2234234234"
let scanner = Scanner(string: input)
var d: Double = 0
if scanner.scanDouble(&d) {
print("d: \(d), d == \(input), \(d == Double(input))")
} else {
print("Failed to scan")
} macOS: $ swift jiras/sr-443.swift
(1.0, 1.2234234234) (1.0, 1.2234234234) true
Testing scanDouble
d: 1.2234234234, d == 1.2234234234, true Linux, as of swift-DEVELOPMENT-SNAPSHOT-2020-06-13-a ~/swift-build/toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-06-13-a-ubuntu18.04/usr/bin/swift jiras/sr-443.swift
CGPoint(x: 1.0, y: 1.2234234234) CGPoint(x: 1.0, y: 1.2234234234) true
Testing scanDouble
d: 1.2234234234, d == 1.2234234234, true |
Additional Detail from JIRA
md5: 194c1ac7ca461fcc40bb81483d2a489b
Issue Description:
prints:
Expected result is true.
The text was updated successfully, but these errors were encountered: