
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Double Variable to String in Swift
This tutorial will discuss how to write swift program to convert double type variable to int.
Swift support various datatypes and double and string are one of them. String is an ordered collection of characters. For example: "TutorialsPoint", "Pinky", etc. To create a string type variable, we use String keyword. Whereas Double is used to represent 64-bit floating point numbers. For example, 34.55656, 9.8283, etc. To create a double type variable, we use Double keyword.
To convert double type variable into string we uses String() function. This function convert any data type into string.
Syntax
Following is the syntax ?
String(variableName)
Below is a demonstration of the same ?
Input
Suppose our given input is ?
Num = 52.324
Output
The desired output would be ?
String = 52.324
Example
The following program shows how to convert double type variable to string.
import Foundation import Glibc // Double type variable var mynum : Double = 73.93 // Convert double into string // Using String() function var myVar = String(mynum) print("String:", myVar) print("Type of myVar variable:", type(of: myVar))
Output
String: 73.93 Type of myVar variable: String