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#

cecil merrell
cecil merrell
6,873 Points

floats instead of double.

Why is the video not using floats. the word double simply doubles the space allotted in memory for that variable. instead use float for it and keep memory usage low. anyone correct me if i'm wrong on this.

https://teamtreehouse.com/library/doubles

1 Answer

Steven Parker
Steven Parker
231,210 Points

:point_right: The standard format for floating point numbers is double.

Storage is rarely an issue in modern computers, and math hardware is generally optimized for doubles. The only likely legitimate uses for float that come to mind are:

  • the program is for a very small embedded system (in which case you're not likely to be using C#)
  • the program operates on massive amounts of data, and the loss of precision is not important
  • the target system has hardware optimization for float but not double, and speed is a concern but precision is not.