Character Encoding & Handling doubles Pepper. Character encoding schemes EBCDIC – older with jumps in alphabet ASCII 1967 (7 bit)– Handled English, –ASCII.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Some computer fundamentals and jargon Memory: Basic element is a bit – value = 0 or 1 Collection of “n” bits is a “byte” Collection of several bytes is.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Using Binary Coding Information Remember  Bit = 0 or 1, Binary Digit  Byte = the number of bits used to represent letters, numbers and special characters.
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
Using Binary Coding Information Remember  Bit = 0 or 1, Binary Digit  Byte = the number of bits used to represent letters, numbers and special characters.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
Working with the data type: char  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
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.
Data Representation (in computer system) Computer Fundamental CIM2460 Bavy LI.
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Date: Session III Topic: Number Systems Faculty: Anita Kanavalli Department of CSE M S Ramaiah.
CIS 234: Character Codes Dr. Ralph D. Westfall April, 2011.
CHARACTERS Data Representation. Using binary to represent characters Computers can only process binary numbers (1’s and 0’s) so a system was developed.
Simple Data Type Representation and conversion of numbers
11 Chapter 3 DECISION STRUCTURES CONT’D. 22 FORMATTING FLOATING-POINT VALUES WITH THE DecimalFormat CLASS We can use the DecimalFormat class to control.
Agenda Data Representation – Characters Encoding Schemes ASCII
The character data type char
Input & Output: Console
Numeric precision in SAS. Two aspects of numeric data in SAS The first is how numeric data are stored (how a number is represented in the computer). –
Computer Science 111 Fundamentals of Programming I Number Systems.
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Number Systems Spring Semester 2013Programming and Data Structure1.
Binary, Decimal and Hexadecimal Numbers Svetlin Nakov Telerik Corporation
C Tokens Identifiers Keywords Constants Operators Special symbols.
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
1 Lecture 2  Complement  Floating Point Number  Character Encoding.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Agenda ASCII char N int Character class char N String Bitwise operators homework.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
Introduction to Programming
THE BINARY NUMBER SYSTEM “There are only 10 types of people in this world: Those who understand BINARY and those who do not.”
The character data type char. Character type char is used to represent alpha-numerical information (characters) inside the computer uses 2 bytes of memory.
Copyright Curt Hill Variables What are they? Why do we need them?
PROCESSING Types. Objectives Be able to convert between binary and decimal numbers. Be able to declare and initialize character variables and constants.
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Chapter 7 C supports two fundamentally different kinds of numeric types: (a) integer types - whole numbers (1) signed (2) unsigned (b) floating types –
Java – Variables and Constants By: Dan Lunney. Declaring Variables All variables must be declared before they can be used A declaration takes the form:
Characters and Strings
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
THE CODING SYSTEM FOR REPRESENTING DATA IN COMPUTER.
Lecture Coding Schemes. Representing Data English language uses 26 symbols to represent an idea Different sets of bit patterns have been designed to represent.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Information and Computer Sciences University of Hawaii, Manoa
BlueJ Tester By Pepper.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Chapter 2 Basic Computation
Chapter 4 – Fundamental Data Types
Chapter 6: Data Types Lectures # 10.
EPSII 59:006 Spring 2004.
Multiple variables can be created in one declaration
Lecture Note Set 1 Thursday 12-May-05
Chapter 2 Basic Computation
Introduction to Programming
An overview of Java, Data types and variables
BlueJ Tester By Pepper.
Dr. Clincy Professor of CS
Differences between Java and C
How Computers Store Data
C Programming Getting started Variables Basic C operators Conditionals
Primitive Types and Expressions
ASCII and Unicode.
Presentation transcript:

Character Encoding & Handling doubles Pepper

Character encoding schemes EBCDIC – older with jumps in alphabet ASCII 1967 (7 bit)– Handled English, –ASCII extended (8 bit) – handled special characters such as ñ and £ UNICODE (16 bits) – all language – not Klingon, Egyption hieroglyphics (sometimes uses fewer bits)

Print Unicode table Create a for loop to run 340 times Convert count to char with a cast char x = (char) count; Print "When the number is " + count + " the character is " + x Be sure to set unlimited buffering on your BlueJ window.

character printing code public class characters { public static void main() { for (int count = 1; count < 500; count++){ char x = (char) count; System.out.println("When the number is " + count + " the character is " + x); }}}

Doubles – not exact Stored binary, so.41 is actually a repeating sequence starting with hexadecimal-converter.html To explain how decimal portions convert: conversion-method.html

Converting 41/100 to binary PlaceEquationResult 1Note decimal. 2.41*2 = *2 = *2 = *2 =.560 Result: a repeating pattern of:

doubles – check equal small differences mean little errors creep in. Math.abs(dollars1 - dollars2) <.001 ex: Write a program to Multiply.41 *.41 and compare it to.1681 –print the values so you see the diff –try an == comparison to see it fail –try the test for no more than.001 off

double – check equal public class testdouble { public static void main() { double x =.41*.41; double y =.1681; System.out.println("x is " + x + " and y is " + y); if (x == y) { System.out.println("match with equal sign"); } else { System.out.println("no match with equal sign"); } if (Math.abs(x-y)<.001) { System.out.println("match"); } else { System.out.println("no match"); } }}

printing double System.out.printf("x is %.2f ", x); OR import java.text.DecimalFormat; DecimalFormat twoDec = new DecimalFormat("0.00"); System.out.println("x is " + twoDec.format(x));

More on Decimal Formatter DecimalFormatter object knows: How to print decimals Package to import: import java.text.DecimalFormat; How to create a DecimalFormatter for your numbers: DecimalFormat percentage2 = new DecimalFormat(“0.00%”); How to use a DecimalFormatter to print to your screen: System.out.println(percentage2.format(.308)); // will print 30.80% Different format options: 0 = required position # = show it if you have it % = make it a % (mult by 100) E = E notation (scientific) Now you change your program to print x with only 2 decimal places

Printf printf command: Just like println, but uses variables inside string start % and end character. %, then size of whole number, then decimal places and then type d = int f = float s = string c = char