Difference between revisions of "Constants - Variables - Data Types"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
m
m
Line 13: Line 13:
 
<syntaxhighlight lang="csharp">457568368</syntaxhighlight>
 
<syntaxhighlight lang="csharp">457568368</syntaxhighlight>
  
*Double is used to store numbers where there are numbers before and after the decimal point.
+
*Double is used to store numbers where there are numbers before and after the decimal point, using 64 bits of memory.
  
 
<syntaxhighlight lang="csharp">3.3</syntaxhighlight>
 
<syntaxhighlight lang="csharp">3.3</syntaxhighlight>
  
*Decimal is used for numbers only after the decimal point.
+
*Decimal is used to store larger numbers with information before and after the decimal point, using 128 bits of memory.
  
<syntaxhighlight lang="csharp">.3</syntaxhighlight>
+
<syntaxhighlight lang="csharp">12.593</syntaxhighlight>
  
 
*Character is used to store single letters.
 
*Character is used to store single letters.

Revision as of 18:54, 16 December 2016

There are 9 types of data types. These include boolean, string, integer, double, decimal, character, byte, float and long.

  • Boolean is a binary value, being either true or false.
true
  • String is used for storing characters in word form.
"hello world"
  • Integer is used to store whole numbers (32 bit values).
457568368
  • Double is used to store numbers where there are numbers before and after the decimal point, using 64 bits of memory.
3.3
  • Decimal is used to store larger numbers with information before and after the decimal point, using 128 bits of memory.
12.593
  • Character is used to store single letters.
'A'
  • Byte is used to store a byte( eight 1's or 0's).
00101101
  • Float is used to store a 32 bit decimal number, which must be defined as being a float using "F" or "f" to distinguish it from a double, or it may cause compilation errors.
9.4F
  • Long integer is also used to store whole numbers (However these are 64 bit values).
7846354759340276482
  • Constants are used to create a variable of a specified data type that can never be changed after declaration, all global variables should be declared constant.
const int 32