# Data types

You will have met data types before in ICT when using databases or spreadsheets. Let's take a look at some different types of data...

• Integers (including Short & Long)
• Whole positive numbers
• Typically 4 or 8 bytes in size (but can also be 2, 16 or 32 bytes)e.g. 104 31 12,976
• Strings
• Collection of alpha-numeric characters, white space and punctuation.
• Typically 1 or 2 bytes per character (depending on encoding used)e.g. "as54sfgjf/.dfg4 " "wibble" "Rock n Roll!"
• Booleans
• Either TRUE or FALSE
• 1 byte (really only needs 1 bit, but that makes things complicated!)e.g. TRUE/FALSE ON/OFF 1/0
• Character
• Single character
• Any alpha-numeric character, whitespace or punctuation... but only one!
• Typically 1 or 2 bytes per character (depending on encoding used) e.g. 'g' '!' '7' '@' ' ' 'Z'
• Real (Double, Single, Float etc..)
• Decimal or whole numbers x Positive or negative numbers
• More versatile data type than an integer
• Typically 8 or 16 bytes (but can also be 4, 32 or 64 bytes)e.g. -12 37.285 -0.65 62459.7777777779

### Numeric operations

Normal numeric operations can be used as part of your code...

Operation Description Operator Example
+
x=y+z
Subtraction Subtract one value from another
-
x=y-z
Mulitplication Multiply two or more values togther
*
x=y*z
Division Divide one value by another
/
x=y/z
Mod Divide one number by another and only keep the remainder
MOD
x=y MOD z
Div Divide on value by another and only keep the quotient
DIV
x = y DIV z

### Boolean operations

Boolean operations can be used to perform conditional tests for selection (IF statements) and Iterative constructs (check when to exit a loop). For more detail on this go back to the binary logic section

Operation Description Operator Example
AND Performs logical AND operation
AND [&&]

if ((x>y> AND (x>z))

if ((x>y) && (x>z))

OR Performs logical OR operation
OR [| |]

if ((x>y> OR (x>z))

if ((x>y) | | (x>z))

NOT Performs logical NOT operation
NOT [!]

while (!found)