Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics (retired) Types Numbers and Booleans

Aaron Green
Aaron Green
988 Points

I am not seeing commas or decimal points in my intergers or doubles like in the video, do I need to change a preference?

"let year = 2014" is NOT showing 2,104, it's showing 2014 "var version = 1.0" is NOT showing 1.0, it's showing 1

I am not sure if this even matters?

I'm totally new to xcode and Swift, thank you!

2 Answers

I don't really get your question , however to show decimal its either you use double or float like :

          var number :Double = 2.3333
          var numbers :Float = 56.333545

Remember Int is for integers and if you are passing decimal value to it, it will convert it to integer .For example

                       var numbers :Int = 1.36

It will display 1 that is it ... Hope that helps.

Aaron Green
Aaron Green
988 Points

Thanks for the quick reply, sorry if it wasn't a clear question. In the video example, the instructor's output had a comma in 2,014 without having to use " var numbers :Int = 1.36", and had a decimal point in the the second example without having to use Double or Float. However, when I wrote the same syntax, there was no comma or decimal point.

I am not sure if this even matters, but if it does, I am wondering whether or not the code I wrote was wrong, or if there is something I have to change in xcode.

So when I write: let year = 2014 ; it shows up as 2014, NOT 2,014 like in the video or var version = 1.0 ; it shows up as 1, NOT 1.0 like in the video.

Is this clearer? It's possible this doesn't even mean anything, but I am wondering if I'm doing something wrong that I can't get my output to look like the instructor's.

Or maybe He had it as String let number = "2,014"

William Saccente
William Saccente
499 Points

No I am having the same issue when I write let year: Int = 2014 it only shows as 2014 instead of 2,014 like in the video, and the same with the var version: Double = 1.0 it only shows as 1 in the output for the standard editor

I would like an answer to this question, too. Why are Amit's numbers in the video displaying with commas? Is this an option in Xcode that needs to be turned on?