• Home
  • About
  • Our Apps
  • Learn
  • Contact
Login

Register

Login
Seemu Apps Seemu Apps
  • Home
  • About
  • Our Apps
  • Learn
  • Contact

Convert String to Number (Integer, Float, Double)

Home ios Convert String to Number (Integer, Float, Double)

Convert String to Number (Integer, Float, Double)

Apr 21, 2016 | Posted by Andrew | ios, swift, tutorial, xcode |

Converting a string to a number is simple thanks to Swift. The following code will take the number 42 and convert it to an int, float and double.

        let number = 42
        
        let int = Int(number)
        let float = Float(number)
        let double = Double(number)
        
        print(int)
        print(float)
        print(double)

It will then print the results to the console which are:

42
42.0
42.0

 

 

Tags: convertdoublefloatintnumberstring
1
Share

About Andrew

Andrew is a 24 year old from Sydney. He loves developing iOS apps and has done so for two years.

You also might be interested in

Swift check if an element is in an array

Apr 12, 2016

Checking if an element is an an array in swift[...]

Converting a NSDate to a String and String to a NSDate

Mar 30, 2016

Converting a NSDate to a String and back again is[...]

Split String into Array by Words

Apr 5, 2016

Splitting a string into an array based on the word[...]

Welcome

Hi I am Andrew and welcome to Seemu Apps! Have a look around, we provide tutorials for primarily iOS apps.
Bluehost website hosting discount

Seemu’s Studio Setup

Blue Yeti Microphone
Rode Stand
Spider Shock Mount
Mac Keyboard Cover
Screenflow - recording software

Contact Us

We're currently offline. Send us an email and we'll get back to you, asap.

Send Message

Footer

:)

© 2026 · Your Website. Theme by HB-Themes.

  • Home
  • About
  • Our Apps
  • Learn
  • Contact
Prev Next