Swift Int Float Double String type convert

In the C language which,To convert type does not seem to how difficult,The learning Swift when there is confusion。

Which of them seem to remember spoken tutorial,But remember,This has found,On record:

To convert to Double Int or Float ,It is as follows

To convert Int,It is as follows:

To convert to String,It is as follows:

Int To String Switch, etc.,It is as follows


There is an extension method can retain double digits,You want to keep the number of bits can be manipulated

d.format(“.2”)Two digits after the decimal point is reserved.,In this case the output will become "4.46"


Original article written by Gerber drop-off:R0uter's Blog » Swift Int Float Double String type convert

Reproduced Please keep the source and description link:https://www.logcg.com/archives/1014.html

About the Author


The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Leave a Reply

Your email address will not be published. Required fields are marked *