Data Types The type states how much and what kind of data the variable can store. integers- whole numbers no fractional parts int, short, long floating.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Constants and Data Types Constants Data Types Reading for this class: L&L,
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
Simple Data Type Representation and conversion of numbers
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Data Types Copyright © 2006 Patrick McDermott College of Alameda
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
CISC105 – General Computer Science Class 9 – 07/03/2006.
CSE1222: Lecture 2The Ohio State University1. mathExample2.cpp // math example #include using namespace std; int main() { cout
Primitive Variables.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
© A+ Computer Science - Variables Data Types © A+ Computer Science - Lab 0B.
Primitive Variables.
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
Copyright © – Curt Hill Types What they do.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
© A+ Computer Science - A reference variable stores the memory address of an object. Monster fred = new Monster(); Monster sally.
Variables and Types Java Part 3. Class Fields  Aka member variable, field variable, instance variable, class variable.  These are the descriptors of.
Objects Variables and Constants. Our Scuba Problem #include // cin, cout, > using namespace std; int main() { const double FEET_PER_ATM = 33.0, LBS_PER_SQ_IN_PER_ATM.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Primitive Data Types 1 In PowerPoint, point at the speaker icon, then click the "Play" button.
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
A data type in a programming language is a set of data with values having predefined characteristics.data The language usually specifies:  the range.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
Integer VariablestMyn1 Integer Variables It must be possible to store data items in a program, and this facility is provided by variables. A variable is.
Lecture 4 Monday Sept 9, Variables and Data Types ►A►A►A►A variable is simply a name given by the programmer that is used to refer to computer storage.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Constants, Data Types and Variables
Fundamentals 2.
Week 2 - Wednesday CS 121.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Variable Declarations
Chapter 6: Data Types Lectures # 10.
Documentation Need to have documentation in all programs
ITEC113 Algorithms and Programming Techniques
EPSII 59:006 Spring 2004.
Variables ,Data Types and Constants
Unit-2 Objects and Classes
Computers & Programming Languages
© A+ Computer Science - VARIABLES © A+ Computer Science -
Data Types.
C++ Data Types Data Type
Chapter 2: Java Fundamentals
Storing Information Each memory cell stores a set number of bits (usually 8 bits, or one byte) (byte addressable)
Variables Data Types Lab 0B
Coding Concepts (Data- Types)
Data Types Imran Rashid CTO at ManiWeber Technologies.
Chapter # 2 Part 2 Programs And data
Chapter 2: Java Fundamentals
Introduction to Primitives
Introduction to Primitives
Variables and Computer Memory
© A+ Computer Science - Variables & Data Types © A+ Computer Science - ©A+ Computer Science
Names of variables, functions, classes
Variables and Constants
Section 6 Primitive Data Types
Presentation transcript:

Data Types The type states how much and what kind of data the variable can store. integers- whole numbers no fractional parts int, short, long floating point - real numbers with fractional parts double -real numbers with fractional parts Boolean – true or false

Characters char let = 'A'; char fun = 65; char test = 'a'; char variables are used to store a single letter. char variables are actually integers. char let = 'A'; char fun = 65; char test = 'a'; char go = 97; char what = 48;

Characters char is a 16-bit unsigned int data type. Here is a 16 bit pattern: 000000000110011 char let = 65; ASCII VALUES 'A' – 65 'a' – 97 '0' - 48 char is an unsigned(has no negative range) integer data type. char letter = 97; out.println(letter); //outs a letter = 'A'; out.println(letter); //outs A

ASCII Values 'A' - 65 'B' - 66 'C' - 67 … 'a' - 97 'b' - 98 'c' - 99 … '0' - 48 '1' - 49 '2' - 50 … Once you memorize the starting value for ‘A’, ‘a’, and ‘0’, determining the ASCII values for most letters and numbers is pretty simple.

CHARACTERS (char) char alpha = 'A'; char ascii = 65; char sum = 'B' + 1; System.out.println(alpha); System.out.println(ascii); System.out.println(sum); System.out.println('B'+1);

Memory Memory consists of bits and bytes. 8 bits = 1001 0010 = 1 byte 16 bits = 0101 1001 0100 1001 = 2 bytes The more bits you have the more you can store. The more bits a data type has the more that data type can store. A 64 bit type has much more storage room than an 8 bit type. 64 32 16 8 4 2 1 base 10 value of each binary digit 1 0 1 0 = 10 in base 10 1 1 1 1 = 15 in base 10(4 bit) 1 0 0 0 1 0 0 0 = 136 in base 10 1 1 1 1 1 1 1 1 = 255 in base 10(8 bit) 1 byte = 8 bits

Integer MIN and MAX OUTPUT System.out.println(Byte.MIN_VALUE); System.out.println(Byte.MAX_VALUE); System.out.println(Short.MIN_VALUE); System.out.println(Short.MAX_VALUE); OUTPUT -128 127 -32768 32767 MIN_VALUE and MAX_VALUE are very useful for contest programming. The MIN_VALUE and MAX_VALUE fields store the minimum and maximum values that can be stored in a particular type.

Integer MIN and MAX OUTPUT System.out.println(Integer.MIN_VALUE); System.out.println(Integer.MAX_VALUE); System.out.println(Long.MIN_VALUE); System.out.println(Long.MAX_VALUE); OUTPUT -2147483648 2147483647 -9223372036854775808 9223372036854775807 The MIN_VALUE and MAX_VALUE fields store the minimum and maximum values that can be stored in a particular type.

All Data Types data type memory usage min .. max byte 8 bits -128 to 127 short 16 bits -32768 to 32767 int 32 bits -2 billion to 2 billion long 64 bits -big to +big float -big to +big double char 16 bit unsigned 0 - 65535 This data type chart lists most data type’s memory usage and range of storage values. It is important to know all data types and what each one can store.