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

C# C# Basics (Retired) Perfect Integers and Doubles

Rasmus Hall
Rasmus Hall
1,260 Points

Why even use int?

Why should i even use int? double sounds much better at everything

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi there,

The short answer is Memory. Doubles take up twice as much memory as Integers. Here is one of Stack Overflow's threads on the subject for further reference.

Keep Coding!

:) :dizzy:

Brent Phillips
seal-mask
.a{fill-rule:evenodd;}techdegree
Brent Phillips
Front End Web Development Techdegree Student 12,627 Points

Hey Rasmus,

Also consider data types and appropriate typing - If you know you wont be using fractional values (think of a record ID in a database or the score of a ping pong match) it would be semantically correct to use an Int over a Double in your logic. Keeping track of and using appropriate types helps keep your code clean and easier to debug.

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

In this project it's really up to you if you want to use int or double, but I believe Jeremy McLain says something about int being easier for the computer to work with, and if in a big project you use double instead of int then it could result in a lower performance - not 100% sure though.