- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Swift Program to convert int type variable to double
This tutorial will discuss how to write swift program to convert int type variable to double.
Swift support various datatypes and double and integers are one of them. 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. Whereas Integer represent numeric values like 2, 3, 45, 6, etc. And to create integer type variable we use Int keyword.
To convert int type variable into double we uses Double() function. This function convert any data type into double.
Syntax
Following is the syntax −
Double(variableName)
Below is a demonstration of the same −
Input
Suppose our given input is −
Num = 52324
Output
The desired output would be −
Double = 52324.0
Example
The following program shows how to convert int type variable to double.
import Foundation import Glibc // Integer type variable var mynum : Int = 7393 // Convert integer into double // Using Double() function var myVar = Double(mynum) print("Double:", myVar) print("Type of myVar variable:", type(of: myVar))
Output
Double: 7393.0 Type of myVar variable: Double