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 trialRayhan Miah
2,369 PointsDeclare constant named product the multiply how do i do that
How do i compile it whats the code
// Enter your code below
let firstValue: Int = 2000000000000
let secondValue: Int = 300000000000
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
2 Answers
Greg Kaleka
39,021 PointsHi Rayhan,
Your code is perfect. There's a bug in the challenge. If you reduce the size of your integers to something like 2000 and 3000, you'll be all set.
Pasan Premaratne, it would be good to have an error message if the integers are too large. I assume there's some character limit in the string the back-end is checking - maybe that could be added to the validation?
Cheers
-Greg
Rayhan Miah
2,369 PointsThank you it worked
Pasan Premaratne
Treehouse TeacherPasan Premaratne
Treehouse TeacherThere isn't a bug here. Run the code in a Playground and you'll get a crash as well. This is known as an overflow error.
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsOh man - I didn't even think of that. 2000000000000 * 300000000000 = too big for an Int - got it.