When I run an Xcode playground and use the pow() function, it's ignoring the exponent and returning only the base. If I run this code in a swift playground on an iPad or execute it in the REPL, I get the expected result (9). But in Xcode, it just fails.
Xcode playground failing on pow() function?
Which version of Xcode ? Which version of iOS ?
I tested in Xcode (15) Playground, no problem:
I tested in code (simulator iOS 15): no problem either, no crash, correct value 9.0
I tested on an iPad with Swift playground: no problem, correct result.
So the culprit seems to be in Monterey
Indeed. That’s just weird. And it’s not just pow that triggers the problem. Other functions, like log, behave similarly.
jpurnell, Please file a bug about this, and then post your bug number here, just for the record
Note that Xcode 13.0 is not really rated for macOS 12 beta development — for that you should be using Xcode 13.0b5 which includes the macOS 12 beta SDK — but this problem reproduces with 13.0b5 as well.
ps If you’re doing a bunch of numerics stuff then I recommend that you lean in to the Swift Numerics. The code you posted pulls in the C pow API via Foundation. That API work in Swift, but Swift Numeric is much more thoroughly thought through.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Interesting. I just saw this thread on Swift Forums and I think it explains the behaviour described above.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"