Begginner questions about c# data types

Started by
1 comment, last by jfree 14 years, 2 months ago
I am learning c# from a book, and im on the part about data types (ch. 2) maybe im just slow, but there are a few things i dont quite understand after reading, can anyone explain some of these in slow people terms? 1. Whats the difference between float and double, he says single point percision, and double is double percision. what does that mean? 2. also i still dont get the difference between a signed and unsigned variable. 3. also he mentions literals, what exacty is a literal? thanks, jfree
Advertisement
1) A float is a 32-bit representation of a decimal number, where as a double is 64-bit. What this really means is that because the double has twice as many bits as a float it can be more precise in the numbers it represents. For the most part you can use either one to accomplish the same goal. To read more about how the numbers are stored and why there is error storing numbers this way read this.

2) A signed variable is one that can be positive or negative, whereas a unsigned variable cannot. A signed int can be anywhere from -2,147,483,648 to 2,147,483,647 and a unsigned int (uint in c#) can be anywhere from 0 to 0 to 4,294,967,295. This again is based purely on the binary representation of the number and how we represent the binary in decimal.

3)A literal would be like a number that you type in yourself (like 5 for instance). In the expression:
int a = 5;
5 is a literal.
thanks :)

This topic is closed to new replies.

Advertisement