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,038 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
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
Henrik Christensen
Python Web Development Techdegree Student 38,316 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.