[swift-users] How to print formated "%.9f" Double? Swift 2.2 ?
Harlan Haskins
harlan at harlanhaskins.com
Thu Dec 10 15:50:08 CST 2015
I’m not sure what happened to String(format:), but I haven’t been able to get it to work either.
It’s printing its argument as a tuple.
I think variadic functions aren’t implemented in the dev version of Swift?
main.swift:3:1: error: 'printf' is unavailable: Variadic function is unavailable
printf("%0.2d", 4.555555555)
^~~~~~
SwiftGlibc.printf:2:13: note: 'printf' has been explicitly marked unavailable here
public func printf(__format: UnsafePointer<Int8>, _ varargs: Any...) -> Int32
> On Dec 10, 2015, at 4:39 PM, Isaac Gouy via swift-users <swift-users at swift.org> wrote:
>
>
> For example,
>
> print( String(format: "%.3f", 1.23489) )
>
> $ /usr/local/src/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu15.10/bin/swiftc test.swift
>
> $ ./test
> ("%.3f", 1.23489)
>
> Not 1.235
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151210/753849fd/attachment.html>
More information about the swift-users
mailing list