# Advanced Tutorials. Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD

Size: px
Start display at page:

Download "Advanced Tutorials. Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD"

## Transcription

1 Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD ABSTRACT Understanding how SAS stores and displays numeric data is essential for both accurate computations and effective, useful, reports and tables. SAS stores the values of all numeric variables in floating-point representation. This paper begins with a brief, practical, overview of floating point representation and how it relates to programming questions regarding length, precision, and efficient use of disk space. I will discuss situations where numeric length should not be reduced, even if the range of integer values would appear to permit it. For saving disk space, I'll show the advantages of the SAS V8 COMPRESS=BINARY option. How SAS stores numbers also affects the use of comparison operators, and I will discuss the use of numeric functions such as ROUND, FLOOR and CEIL to achieve program goals. The use of formats for the effective display of numeric data will also be discussed. In particular I will explain the use of the 'w' (width) and 'd' (decimal) values of formats such as COMMAw.d, DOLLARw.d and PERCENTw.d. The goal of this paper is to give the SAS programmer a clear conception of how SAS stores and displays numbers and to therefore increase the programmer's ability to achieve precise program and project objectives. INTRODUCTION This paper looks at some important properties of two different, but related, aspects of numeric data in SAS. The first is how numeric data are stored (i.e. how a number is represented in the computer). The second is how numeric data are displayed (i.e. how a number appears on a screen or piece of paper). Different systems use different methods to store numbers. SAS uses floating point representation and, by default, stores numeric values using eight bytes. This paper will begin with a brief, practical, sketch of floating point representation and some of its underlying concepts. The goal of this sketch is not to exhaustively explain how to translate base 10 numbers into floating point representation, but rather to give you a moreconcrete sense of how the SAS system interprets a statement such as: (1) LENGTH NVAR1 3 ; One reason for not delving into the minutiae of floating point representation is that it is rarely of practical value in the day-today work of SAS programming and making decisions concerning the LENGTH of numeric data. It is better to have a small set of guiding principles for making decisions in a timely manner. Of course it is always good to know where to go to get detailed information if you need it, and the RESOURCES section at the end of this paper contains two useful references from SAS Institute (they include additional references). SAS displays numeric data using either a default FORMAT or one that has been specified by the programmer. This paper will discuss the SAS formats COMMAw.d, DOLLARw.d and PERCENTw.d. Although not as complex a topic as floating point representation, not knowing the proper use of these formats can lead to lots of frustration in generating reports and tables. HOW SAS STORES NUMBERS There's quite a bit of detail in this section. In general, there would seem to be little reason to pay attention to this level of detail in making day-to-day programming decisions. So why go to the trouble of devoting time to it? For two reasons: (i) so that you are in a position to evaluate the general claims made here in terms of your particular situation; (ii) you may, at some point, encounter a programming problem that requires a detailed understanding of how SAS stores numbers and how this differs from how SAS displays numbers. FLOATING POINT REPRESENTATION Most papers on floating-point representation and numeric precision only tell part of the story. The part of the story I'm going to tell focuses on giving you enough information to understand, or, at least give you a jumpstart in understanding, more-detailed discussions of these topics. I also hope it allows you to evaluate the guidelines that I give at the end of this section. The basic unit of storage is the bit (binary digit). As the term binary suggests, there are two possible values: 0 and 1. A sequence of 8 bits is called a byte. SAS stores numeric data using 64 bits (eight bytes). The eight bytes are divided among 3 different types of information: the sign, the exponent, and the mantissa. An important fourth type of information is the base, i.e. the number raised to a power. These are terms for the parts of a number in scientific notation. Floating point representation is just one form of scientific notation. In this system, each number is represented as a value (the mantissa) between 0 and 1 raised to a power of 2 (in a binary, base 2, system). The term decimal in 'decimal point' assumes a base 10 system, so the term 'radix point' is often used when the base is not 10. The radix point for a number is moved (i.e. it floats in the picturesque speech of computer science) to the left until the number is a fraction between 0 and 1. If we use the more-familiar base 10 system, the number 234 would be represented as.234 x Placing the decimal point to the left of the number is called 'normalizing the value.' This normalization yields a value between 0 and 1. In addition to the mantissa (.234) and the exponent (3), a full representation of 234 would include the sign (negative or positive).

2 Here's the byte layout for a 64-bit number in the IEEE system used by Windows (where S = sign; E = exponent; and M = mantissa): (2) SEEEEEEE EEEEMMMM MMMMMMMM MMMMMMMM byte 1 byte 2 byte 3 byte 4 MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM byte 5 byte 6 byte 7 byte 8 That is, there's 1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa. The number of exponent bits determines the magnitude of the numbers that can be represented. The number of mantissa bits determine the precision. For example, an IBM mainframe system will use 56 bits for the mantissa, allowing for greater precision than you get on a PC. In the following discussion I will focus on the mantissa since that is the part of the representation affected by the LENGTH statement. For 52-bit systems, the functional equivalent of 53 bits is achieved by assuming an 'implied' bit. That is, since the only possible non-zero digit is 1, we can just assume an initial mantissa bit with a value of 1. We'll see that the existence of this implied bit solves an apparent puzzle when we look at numbers in binary where all the mantissa bits have values of 0. When you use a LENGTH statement such as (1), you are telling the SAS system to only use the first 3 bytes to store the number, i.e. bytes 1-3 in (2). You save 5 bytes per file record this way, but you are potentially losing precision because you are sacrificing 40 mantissa bits. Note that you cannot specify length in terms of bits, or specify which bytes to use. If LENGTH is 3 then you only have the first 3 bytes in (2). INTEGERS Below is a table showing (what is often referred to as) the largest integer that can be represented accurately for a given LENGTH specification. The numbers in the table will be different for IBM and VAX computers (consult the SAS Companion for your operating system). LENGTH IN BYTES LARGEST INTEGER (PC/UNIX) 2 NOT ALLOWED 3 8, ,097, ,870, ,438,953, ,184,372,088, ,007,199,254,740,992 Now let's look at the 64-bit representation of 8,192 and 8,193 to see why 8,192 is the 'largest integer' that can be accurately represented. You can create 64-bit output by using the BINARY64. format (The spaces between bytes were added later). (3) The 64-bit representation of 8,192: (4) The 64-bit representation of 8,193: The first thing to notice is that the difference between 8,192 and 8,193 is in byte 4. If you are limited to the first 3 bytes then this difference is eliminated and, as far as the computer is concerned, the numbers are identical (because bytes 1-3 are identical). We can show this with the SAS program in (5). (5) DATA ONE ; LENGTH VAR1 VAR2 3 ; VAR1 = 8192 ; VAR2 = 8193 ; DATA TWO; PUT VAR1=22.16 ; PUT VAR1=BINARY64. ; PUT VAR2=22.16 ; PUT VAR2=BINARY64. ; Here's the LOG output you'd get: (6) VAR1= VAR1= VAR2= VAR2= There are a couple of things going on here we need to unpack. First, VAR2 was initially assigned a value of 8,193, but in data set TWO it's 8,192. The reason is that the LENGTH specification of 3 has removed the distinguishing information in byte 4. When SAS stored this variable it only used three bytes. Second, and this is a point we'll come back to later, in the DATA step (i.e. the program data vector [PDV]) SAS uses the full 8-byte representation of numbers (Note that, for character variables, the LENGTH statement applies both to the PDV and the output data set). If a variable was stored as LENGTH 3, then bytes 4 through 8 are 'filled in' with zeros. This is what has happened with VAR1 and VAR2. When data set ONE is stored, VAR1 and VAR2 are stored with 3 bytes. When they are read for the DATA step that creates TWO, they are expanded to eight bytes, with the last 5 bytes all zeros. For VAR1 (8,192) this does not result in any loss of precision because the last 5 bytes are all zeros in the original 8-byte representation. Note that there are no mantissa bits with a value of 1. This is because 8,192 is a power of 2 (2 13 ) and so only the implied bit needs a value of 1. 2

3 For VAR2 (8,193) there is a loss of precision when stored as LENGTH 3 because the 4 th bit contains information. This information is lost when the data set is stored. In this case the filling in of bytes 4-8 with zeros results in a value equivalent to 8,192 so the original value of VAR1 (8,193) has been changed to 8,192. Let's expand on the DATA step in (5) to illustrate a couple of points. (7) DATA ONE ; LENGTH VAR1 VAR2 VAR3 3 ; VAR1 = 8192 ; VAR2 = 8193 ; VAR3 = ; PUT VAR1=22.16 ; PUT VAR1=BINARY64. ; PUT VAR2=22.16 ; PUT VAR2=BINARY64. ; PUT VAR3=22.16 ; PUT VAR3=BINARY64. ; VAR1= VAR1= VAR2= VAR2= VAR3= VAR3= DATA TWO; PUT VAR1=22.16 ; PUT VAR1=BINARY64. ; PUT VAR2=22.16 ; PUT VAR2=BINARY64. ; PUT VAR3=22.16 ; PUT VAR3=BINARY64. ; VAR1= VAR1= VAR2= VAR2= VAR3= VAR3= The first thing to notice is that the LENGTH statement in the first DATA step has no effect on the length of the variables created in the DATA step. The LENGTH statement only takes effect when the variables are stored. The second thing to notice is that (unlike with VAR2: 8,193), there is no loss of precision when VAR3 (16,384) is stored. This is because in the full, 8-byte, representation of 16,384, bytes 4-8 contain only zeros. In fact, because 16,384 is a power of 2 (2 14 ), only the implied mantissa bit has information. So it's not actually true that 8,192 is the largest integer that can be accurately represented with LENGTH 3 (on a PC or UNIX system). What is true is that 8,192 is the largest integer of a continuous range of integers that can be accurately represented with 3 bytes. The same is true for the other integers in the righthand column in the table. These 'largest integer' tables are still handy references for quick decisions, but it's important to know that exceptions exist. FRACTIONS It's also important to remember that these tables apply only to integers. The situation is somewhat different when we look at fractions. Let's compare 1/10 and 1/2. (8) DATA ONE; VAR1 = 1 ; VAR2 = 0 ; DO X = 1 TO 10 ; VAR ; VAR3 = 0 ; DO X = 1 TO 2 ; VAR ; IF VAR1 = VAR2 THEN PUT VAR1 'EQ ' VAR2 ; ELSE PUT VAR1 'NE ' VAR2 ; IF VAR1 = VAR3 THEN PUT VAR1 'EQ ' VAR3 ; ELSE PUT VAR1 'NE ' VAR3 ; If you run this DATA step, the LOG output will be: (9) 1 NE 1 [for 0.1] 1 EQ 1 [for 0.5] The first LOG message looks like a clear contradiction. How can the result be that 1 does not equal 1? The answer, of course, is that the stored value of VAR2 differs from its display form. Here's the 8-byte representation of VAR1 and VAR2: (10) VAR1= VAR2=

4 Once we see the 8-byte representation, it's clear that VAR1 and VAR2 have different stored values. The output of the comparison also shows that SAS is comparing stored values and not display values. The reason that VAR2 does not equal 1 is because 0.1 cannot be represented precisely in a binary system (though it's straightforward in a decimal system) and this imprecision iterates with each addition in the DO loop. Now let's compare VAR1 with VAR3: (11) VAR1= VAR3= Here we see that adding 0.5 to 0.5 results in a stored value that is equal to 1. Why here and not with 0.1? Notice that, in contrast to VAR2, bytes 3-8 are all zeros. In fact, in binary representation, 0.5 looks a lot like 8,192 and 16,384. This is because these numbers are all powers of 2: 0.5 = 2-1. GUIDELINES FOR STORAGE It's clear that the magnitude of a number is an imperfect predictor of whether or not it can be accurately represented with a reduced number of bytes. The numbers 1/2 and 16,384 can be accurately represented with 3 bytes, but 8,193 cannot. Let's consider a numeric variable HOSPITAL_DAYS that indicates how many days in a year a person was in the hospital. The largest possible value is 365 in non-leap years. But let's assume that half-days (but no other fractions) are possible, so values such as are allowed. This is a variable that, despite the non-integer values, is a candidate for LENGTH 3. Recognizing candidates for reduced LENGTH is an important part of the decision process, and knowing a bit (no pun intended) about how SAS stores numbers is essential for this. The larger question concerns other factors that are involved in making such a decision. Here's an example that illustrates how you often need to consider a larger context when making, what appear to be, narrow, technical decisions. Assume that you have a SAS data set with a variable for annual out-of-pocket dental expenditures. The values are all integers and the largest value for this variable on the file is 8,192. Should you set LENGTH 3? Let's say you do. Fast forward a year or so and the task is to input this file, increase dental expenditures by 13% (to account for inflation), and round the result to the nearest integer. Here's a DATA step that shows the potential problem. (12) DATA ONE; LENGTH DENTOOP1 3 ; DENTOOP1 = 8192; DENTOOP2 = 8192; DATA TWO; DENTOOP1 = ROUND((DENTOOP1*(1.13)); DENTOOP2 = ROUND((DENTOOP2*(1.13)); PUT DENTOOP1= ; PUT DENTOOP2= ; DENTOOP1=9256; DENTOOP2=9257; In data set ONE the variable DENTOOP1 has a LENGTH of 3 whereas DENTOOP2 has a LENGTH of 8 (the default). After the 13% increase and rounding in the second DATA step, we see that the modified values depend on the LENGTH specification. What you don't want is a phone call from the client asking why, when a simple check with a hand calculator is used, they get a value of 9257 (i.e rounded) but your program output is Finding out why could ruin your whole afternoon. Of course the problem could have been avoided if the programmer updating dental expenditures had simply (i) run a PROC CONTENTS and noticed that the LENGTH is 3 bytes; (ii) known the interger values for which accuracy is preserved with this LENGTH (iii) run a PROC and noticed that there are values that, if increased by 13%, would exceed 8,192; (iv) realized that variable attributes like LENGTH are inherited by one data set from another; (v) known how to stop the default attribute inheritance for this variable; and (vi) placed a new LENGTH statement in the DATA step that updated the variable's values. If the steps listed in the last paragraph are second nature to you, everyone you work with, and everyone you will ever hire, then this would favor a decision to reduce numeric length based simply on the values in the data set. I would argue, however, for a more conservative approach. This approach would first distinguish between actual and permissible values. By actual values I mean the set of values that happen to be true for a variable on a particular data set. Given reasonable QC, the set of actual values should be a subset of the set of permissible values. Let's take the dental expenditure variable as an example. On the data set I discussed earlier, the maximum value was 8,192. But this just happened to be true. It could have been different. We can contrast this with a numeric variable such as BIRTH_MONTH, which might have a permissible range of 1-12 and be restricted to integers. For various reasons it is possible that, on a particular data set, not all of these are actual values. But the point is that, if LENGTH 3 is set for this variable, it's hard to imagine a situation where values for this variable would ever create imprecision issues. Of course the variable might have a value of 99 or whatever to indicate "UNKNOWN", but, unlike the dental expenditure variable discussed earlier, the permissible range is well defined and clearly within the reduced LENGTH specification. For the HOSPITAL_DAYS variable, given the permissible range, and the fact that the only permissible non-integer is 0.5, I would decide to store this variable as LENGTH 3. 4

6 Let's modify (8) as follows: (18) DATA ONE; VAR1 = 1 ; VAR2 = 0 ; DO X = 1 TO 10 ; VAR ; VAR3 = 0 ; DO X = 1 TO 2 ; VAR ; IF VAR1 = ROUND(VAR2) THEN PUT VAR1 'EQ ' VAR2 ; ELSE PUT VAR1 'NE ' VAR2 ; IF VAR1 = VAR3 THEN PUT VAR1 'EQ ' VAR3 ; ELSE PUT VAR1 'NE ' VAR3 ; If you run this DATA step, the LOG output will be: (19) 1 EQ 1 [for 0.1] 1 EQ 1 [for 0.5] The round function corrects for the imprecision by rounding to the nearest integer. In (18) the rounding is within the comparison, the value of VAR2 is unchanged, i.e. exactly what you see in (10). But you may want to actually change the stored value of the variable. If so, then the DATA step in (20) is what you want. (20) DATA ONE; VAR1 = 1 ; VAR2 = 0 ; DO X = 1 TO 10 ; VAR2= ROUND((VAR2+0.1),.1) ; VAR3 = 0 ; DO X = 1 TO 2 ; VAR ; IF VAR1 = VAR2 THEN PUT VAR1 'EQ ' VAR2 ; ELSE PUT VAR1 'NE ' VAR2 ; IF VAR1 = VAR3 THEN PUT VAR1 'EQ ' VAR3 ; ELSE PUT VAR1 'NE ' VAR3 ; The LOG output of this DATA step will be the same as for (18), but for a different reason. Here the ROUND function is part of the assignment statement and the stored values of VAR1 and VAR2 are equal, as shown in (21). (21) VAR1= VAR2= SAS gives you the choice of rounding for the comparison or rounding the actual value of the variable. With the ROUND function you can specify a round-off-unit as a second argument that allows you to specify the decimal level for rounding. For example, ROUND(N,.1) rounds to the nearest tenth. If you omit the second argument, as in (18), then SAS rounds to the nearest integer, i.e. it assumes a second argument of 1. A reasonable guideline is to store the more-precise (unrounded) values for a variable and round for specific purposes. That way if you ever need the more-precise values, you have them. Of course, as is often true in programming, the trick is being able to distinguish between what you see and what you have. There are situations where the ROUND function itself may be affected by numeric imprecision For a detailed discussion of this issue see TS-230 from SAS Institute. The CEIL and FLOOR functions may also be useful in specific situations. Both functions return integer values, i.e. unlike ROUND, you cannot specify a second argument indicating the decimal level. The CEIL function rounds up to the nearest integer, i.e. it returns the smallest integer that is greater than or equal to the argument. The FLOOR function rounds down to the nearest integer, i.e. it returns the largest integer that is less than or equal to the argument. NUMERIC DISPLAY FORMATS In this section I'm going to discuss three common numeric formats: COMMAw.d, DOLLARw.d and PERCENTw.d. Using these formats is not complicated, but avoiding the frustrating message "At least one W.D format was too small for the number to be printed..." does require knowing, not only your data, but also the particular requirements of the values for w and d. In general, w is a number that specifies the total width of the field. For the COMMAw.d format, the value of w must include the total number of commas the highest value of the variable will need. The number 1,000,000,000 requires a field width of 13. If you want to add 2 decimal places you need to specify COMMA16.2 for 1,000,000, That is, you need to add 3 to the field width, 1 for the decimal point and 2 for the decimal places. You also need to consider the minus sign with negative numbers. For the DOLLARw.d format, you always need to add 1 to the w value for the dollar sign. The DOLLARw.d. format automatically includes commas, so you need to add them into the field width. For both the COMMAw.d and DOLLARw.d formats, the value of d must be either 0 or 2 (omitting any specification for d is equivalent to specifying 0). Whether you specify 0 or 2 for the d value, SAS will round the number if necessary. For example will be displayed as 12 if d is 0, but will be displayed as 13. 6

### Advanced Tutorials AT001. Quality Control With SAS Numeric Data Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD

Quality Control With SAS Numeric Data Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD For everything that exists there are three instruments by which the knowledge of it is necessarily

### ELET 7404 Embedded & Real Time Operating Systems. Fixed-Point Math. Chap. 9, Labrosse Book. Fall 2007

ELET 7404 Embedded & Real Time Operating Systems Fixed-Point Math Chap. 9, Labrosse Book Fall 2007 Fixed-Point Math Most low-end processors, such as embedded processors Do not provide hardware-assisted

### Number Systems and. Data Representation

Number Systems and Data Representation 1 Lecture Outline Number Systems Binary, Octal, Hexadecimal Representation of characters using codes Representation of Numbers Integer, Floating Point, Binary Coded

### Binary Representation and Computer Arithmetic

Binary Representation and Computer Arithmetic The decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D. 4. Since it involved the use of fingers

### Fractions and the Real Numbers

Fractions and the Real Numbers Many interesting quantities are not normally integer-valued: - the mass of a rocket payload - the batting average of a baseball player - the average score on an assignment

### Programming Tricks For Reducing Storage And Work Space Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA.

Paper 23-27 Programming Tricks For Reducing Storage And Work Space Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA. ABSTRACT Have you ever had trouble getting a SAS job to complete, although

### 2.1 Binary Numbers. 2.3 Number System Conversion. From Binary to Decimal. From Decimal to Binary. Section 2 Binary Number System Page 1 of 8

Section Binary Number System Page 1 of 8.1 Binary Numbers The number system we use is a positional number system meaning that the position of each digit has an associated weight. The value of a given number

### Survey Analysis: Options for Missing Data

Survey Analysis: Options for Missing Data Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD Abstract A common situation researchers working with survey data face is the analysis of missing

### Numbering Systems. InThisAppendix...

G InThisAppendix... Introduction Binary Numbering System Hexadecimal Numbering System Octal Numbering System Binary Coded Decimal (BCD) Numbering System Real (Floating Point) Numbering System BCD/Binary/Decimal/Hex/Octal

### Recall that in base 10, the digits of a number are just coefficients of powers of the base (10):

Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

### comp 180 Lecture 21 Outline of Lecture Floating Point Addition Floating Point Multiplication HKUST 1 Computer Science

Outline of Lecture Floating Point Addition Floating Point Multiplication HKUST 1 Computer Science IEEE 754 floating-point standard In order to pack more bits into the significant, IEEE 754 makes the leading

### By the end of the lecture, you should be able to:

Extra Lecture: Number Systems Objectives - To understand: Base of number systems: decimal, binary, octal and hexadecimal Textual information stored as ASCII Binary addition/subtraction, multiplication

### Binary Number System. 16. Binary Numbers. Base 10 digits: 0 1 2 3 4 5 6 7 8 9. Base 2 digits: 0 1

Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

### Digital Fundamentals

Digital Fundamentals with PLD Programming Floyd Chapter 2 29 Pearson Education Decimal Numbers The position of each digit in a weighted number system is assigned a weight based on the base or radix of

### This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

This Unit: Floating Point Arithmetic CIS 371 Computer Organization and Design Unit 7: Floating Point App App App System software Mem CPU I/O Formats Precision and range IEEE 754 standard Operations Addition

### Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend -480 41-36 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until

### Number Representation

Number Representation Number System :: The Basics We are accustomed to using the so-called decimal number system Ten digits ::,,,3,4,5,6,7,8,9 Every digit position has a weight which is a power of Base

### TECH. Arithmetic & Logic Unit. CH09 Computer Arithmetic. Number Systems. ALU Inputs and Outputs. Binary Number System

CH09 Computer Arithmetic CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer Representation Integer Arithmetic Floating-Point Representation

### Solution for Homework 2

Solution for Homework 2 Problem 1 a. What is the minimum number of bits that are required to uniquely represent the characters of English alphabet? (Consider upper case characters alone) The number of

### Chapter 2. Values, Variables, and Types. 2.1 Java Values in DrJava s Interaction Pane

14 Chapter 2 Values, Variables, and Types In this chapter we explore the primitive building blocks that are used to develop Java programs. We experiment with the following concepts within DrJava s interactive

### Radix Number Systems. Number Systems. Number Systems 4/26/2010. basic idea of a radix number system how do we count:

Number Systems binary, octal, and hexadecimal numbers why used conversions, including to/from decimal negative binary numbers floating point numbers character codes basic idea of a radix number system

### Binary Numbering Systems

Binary Numbering Systems April 1997, ver. 1 Application Note 83 Introduction Binary numbering systems are used in virtually all digital systems, including digital signal processing (DSP), networking, and

### CPE 323 Data Types and Number Representations

CPE 323 Data Types and Number Representations Aleksandar Milenkovic Numeral Systems: Decimal, binary, hexadecimal, and octal We ordinarily represent numbers using decimal numeral system that has 10 as

### Data types. lecture 4

Data types lecture 4 Information in digital computers is represented using binary number system. The base, i.e. radix, of the binary system is 2. Other common number systems: octal (base 8), decimal (base

### CHAPTER THREE. 3.1 Binary Addition. Binary Math and Signed Representations

CHAPTER THREE Binary Math and Signed Representations Representing numbers with bits is one thing. Doing something with them is an entirely different matter. This chapter discusses some of the basic mathematical

### Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 INTRODUCTION TO DIGITAL LOGIC

Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 1 Number Systems Representation Positive radix, positional number systems A number with radix r is represented by a string of digits: A n

### Storing Measurement Data

Storing Measurement Data File I/O records or reads data in a file. A typical file I/O operation involves the following process. 1. Create or open a file. Indicate where an existing file resides or where

### Floating Point Numbers. Question. Learning Outcomes. Number Representation - recap. Do you have your laptop here?

Question Floating Point Numbers 6.626068 x 10-34 Do you have your laptop here? A yes B no C what s a laptop D where is here? E none of the above Eddie Edwards eedwards@doc.ic.ac.uk https://www.doc.ic.ac.uk/~eedwards/compsys

### Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation

Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Abstract This paper discusses methods of joining SAS data sets. The different methods and the reasons for choosing a particular

### CSc 28 Data representation. CSc 28 Fall

CSc 28 Data representation 1 Binary numbers Binary number is simply a number comprised of only 0's and 1's. Computers use binary numbers because it's easy for them to communicate using electrical current

### Introduction to IEEE Standard 754 for Binary Floating-Point Arithmetic

Introduction to IEEE Standard 754 for Binary Floating-Point Arithmetic Computer Organization and Assembly Languages, NTU CSIE, 2004 Speaker: Jiun-Ren Lin Date: Oct 26, 2004 Floating point numbers Integers:

### Binary Numbers. Binary Numbers. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria

Binary Numbers Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Wolfgang.Schreiner@risc.uni-linz.ac.at http://www.risc.uni-linz.ac.at/people/schreine

### Technical Paper. Dealing with Numeric Representation Error in SAS Applications

Technical Paper Dealing with Numeric Representation Error in SAS Applications Release Information Content Version: 1.1 June 2014 (This paper replaces TS-230 released in 1992.) Trademarks and Patents SAS

### CHAPTER 1 Overview of SAS/ACCESS Interface to Relational Databases

3 CHAPTER 1 Overview of SAS/ACCESS Interface to Relational Databases About This Document 3 Methods for Accessing Relational Database Data 4 Selecting a SAS/ACCESS Method 4 Methods for Accessing DBMS Tables

### Quiz for Chapter 3 Arithmetic for Computers 3.10

Date: Quiz for Chapter 3 Arithmetic for Computers 3.10 Not all questions are of equal difficulty. Please review the entire quiz first and then budget your time carefully. Name: Course: Solutions in RED

### The programming language C. sws1 1

The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

### Chapter No.5 DATA REPRESENTATION

Chapter No.5 DATA REPRESENTATION Q.5.01 Complete the following statements. i) Data is a collection of ii) Data becomes information when properly. iii) Octal equivalent of binary number 1100010 is iv) 2

### Integer and Real Numbers Representation in Microprocessor Techniques

Brno University of Technology Integer and Real Numbers Representation in Microprocessor Techniques Microprocessor Techniques and Embedded Systems Lecture 1 Dr. Tomas Fryza 30-Sep-2011 Contents Numerical

### Numbers represented using groups of bits (1s and 0s) are said to be BINARY NUMBERS. Binary numbers are said to be in base 2.

DATA REPRESENTATION All data used by computers is in code form, based on the two digits 0 and 1. This is so, in order to reflect the two-state components of which these digital systems are made. Numbers

### FLOATING POINT NUMBERS

FLOATING POINT NUMBERS Introduction Richard Hayden (with thanks to Naranker Dulay) rh@doc.ic.ac.uk http://www.doc.ic.ac.uk/~rh/teaching or https://www.doc.ic.ac.uk/~wl/teachlocal/arch1 or CATE Numbers:

### Binary Numbers. Binary Numbers. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria

Binary Numbers Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Wolfgang.Schreiner@risc.uni-linz.ac.at http://www.risc.uni-linz.ac.at/people/schreine

### A First Book of C++ Chapter 2 Data Types, Declarations, and Displays

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays Objectives In this chapter, you will learn about: Data Types Arithmetic Operators Variables and Declarations Common Programming Errors

### ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,

### School of Informatics, University of Edinburgh

CS1Ah Lecture Note 5 Java Expressions Many Java statements can contain expressions, which are program phrases that tell how to compute a data value. Expressions can involve arithmetic calculation and method

### Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Chapter 3 Data Storage Objectives After studying this chapter, students should be able to: List five different data types used in a computer. Describe how integers are stored in a computer. Describe how

### Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Digital Logic 1 Data Representations 1.1 The Binary System The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer. The system we

### Chapter 4. Computer Arithmetic

Chapter 4 Computer Arithmetic 4.1 Number Systems A number system uses a specific radix (base). Radices that are power of 2 are widely used in digital systems. These radices include binary (base 2), quaternary

### Variables and Constants

HOUR 3 Variables and Constants What You ll Learn in This Hour:. How to declare and define variables and constants. How to assign values to variables and manipulate those values. How to write the value

### Efficient Techniques and Tips in Handling Large Datasets Shilong Kuang, Kelley Blue Book Inc., Irvine, CA

Efficient Techniques and Tips in Handling Large Datasets Shilong Kuang, Kelley Blue Book Inc., Irvine, CA ABSTRACT When we work on millions of records, with hundreds of variables, it is crucial how we

### Chapter II Binary Data Representation

Chapter II Binary Data Representation The atomic unit of data in computer systems is the bit, which is actually an acronym that stands for BInary digit. It can hold only 2 values or states: 0 or 1, true

### (Refer Slide Time: 02:17)

Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #06 IP Subnetting and Addressing (Not audible: (00:46)) Now,

### Innovative Techniques and Tools to Detect Data Quality Problems

Paper DM05 Innovative Techniques and Tools to Detect Data Quality Problems Hong Qi and Allan Glaser Merck & Co., Inc., Upper Gwynnedd, PA ABSTRACT High quality data are essential for accurate and meaningful

### The Essentials of Computer Organization and Architecture. Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003

The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 2 Instructor's Manual Chapter Objectives Chapter 2, Data Representation,

### Number Representation

Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data

### Reading 7 : Program Correctness

CS/Math 240: Introduction to Discrete Mathematics Fall 2015 Instructors: Beck Hasti, Gautam Prakriya Reading 7 : Program Correctness 7.1 Program Correctness Showing that a program is correct means that

### Data Representation Binary Numbers

Data Representation Binary Numbers Integer Conversion Between Decimal and Binary Bases Task accomplished by Repeated division of decimal number by 2 (integer part of decimal number) Repeated multiplication

### 198:211 Computer Architecture

198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored

### CHAPTER 5 Round-off errors

CHAPTER 5 Round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers in computers. Since any

### THE NAS KERNEL BENCHMARK PROGRAM

THE NAS KERNEL BENCHMARK PROGRAM David H. Bailey and John T. Barton Numerical Aerodynamic Simulations Systems Division NASA Ames Research Center June 13, 1986 SUMMARY A benchmark test program that measures

### Data Storage 3.1. Foundations of Computer Science Cengage Learning

3 Data Storage 3.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List five different data types used in a computer. Describe how

### Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

### Computer Organization and Architecture

Computer Organization and Architecture Chapter 9 Computer Arithmetic Arithmetic & Logic Unit Performs arithmetic and logic operations on data everything that we think of as computing. Everything else in

### INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming

INDEX 1) Introduction to C Programming a. What is C? b. Getting started with C 2) Data Types, Variables, Constants a. Constants, Variables and Keywords b. Types of Variables c. C Keyword d. Types of C

### Y = abc = a b c.2 0

Chapter 2 Bits, Data Types & Operations Integer Representation Floating-point Representation Other data types Why do Computers use Base 2? Base 10 Number Representation Natural representation for human

### 1. Convert the following binary exponential expressions to their 'English'

Answers to Practice Problems Practice Problems - Integer Number System Conversions 1. Convert the decimal integer 427 10 into the following number systems: a. 110101011 2 c. 653 8 b. 120211 3 d. 1AB 16

### Presented By: Ms. Poonam Anand

Presented By: Ms. Poonam Anand Know the different types of numbers Describe positional notation Convert numbers in other bases to base 10 Convert base 10 numbers into numbers of other bases Describe the

### Unit 2: Number Systems, Codes and Logic Functions

Unit 2: Number Systems, Codes and Logic Functions Introduction A digital computer manipulates discrete elements of data and that these elements are represented in the binary forms. Operands used for calculations

### Module 5: Interest concepts of future and present value

file:///f /Courses/2010-11/CGA/FA2/06course/m05intro.htm Module 5: Interest concepts of future and present value Overview In this module, you learn about the fundamental concepts of interest and present

### The Decimal System. Numbering Systems. The Decimal System. The base-n System. Consider value 234, there are: Ver. 1.4

2 The Decimal System Numbering Systems 2010 - Claudio Fornaro Ver. 1.4 Consider value 234, there are: 2 hundreds 3 tens 4 units that is: 2 x 100 + 3 x 10 + 4 x 1 but 100, 10, and 1 are all powers of 10

### Field Properties Quick Reference

Field Properties Quick Reference Data types The following table provides a list of the available data types in Microsoft Office Access 2007, along with usage guidelines and storage capacities for each

### Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

### Numerical Matrix Analysis

Numerical Matrix Analysis Lecture Notes #10 Conditioning and / Peter Blomgren, blomgren.peter@gmail.com Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research

### Fixed-point Mathematics

Appendix A Fixed-point Mathematics In this appendix, we will introduce the notation and operations that we use for fixed-point mathematics. For some platforms, e.g., low-cost mobile phones, fixed-point

### Floating-point computation

Real values and floating point values Floating-point representation IEEE 754 standard representation rounding special values Floating-point computation 1 Real values Not all values can be represented exactly

### Chap 3 Data Representation

Chap 3 Data Representation 3-11 Data Types How to representation and conversion between these data types? 3-11 Data Types : Number System Radix : Decimal : radix 10 Binary : radix 2 3-11 Data Types : Number

### Chapter 2: Number Systems

Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

### Bits and Bytes. Analog versus digital

Bits and Bytes Computers are used to store and process data. Processed data is called information. You are used to see or hear information processed with the help of a computer: a paper you ve just typed

### THE BINARY NUMBER SYSTEM

THE BINARY NUMBER SYSTEM Dr. Robert P. Webber, Longwood University Our civilization uses the base 10 or decimal place value system. Each digit in a number represents a power of 10. For example, 365.42

### The Mathematics Driving License for Computer Science- CS10410

The Mathematics Driving License for Computer Science- CS10410 Approximating Numbers, Number Systems and 2 s Complement by Nitin Naik Approximating Numbers There are two kinds of numbers: Exact Number and

### Fractional Numbers. Fractional Number Notations. Fixed-point Notation. Fixed-point Notation

2 Fractional Numbers Fractional Number Notations 2010 - Claudio Fornaro Ver. 1.4 Fractional numbers have the form: xxxxxxxxx.yyyyyyyyy where the x es constitute the integer part of the value and the y

### Data Representation. Representing Data

Data Representation COMP 1002/1402 Representing Data A computer s basic unit of information is: a bit (Binary digit) An addressable memory cell is a byte (8 bits) Capable of storing one character 10101010

### Chapter 2 Numeric Representation.

Chapter 2 Numeric Representation. Most of the things we encounter in the world around us are analog; they don t just take on one of two values. How then can they be represented digitally? The key is that

### ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,

### BINARY-CODED DECIMAL (BCD)

BINARY-CODED DECIMAL (BCD) Definition The binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence. Basics In computing and electronic

### CHAPTER 3 Number System and Codes

CHAPTER 3 Number System and Codes 3.1 Introduction On hearing the word number, we immediately think of familiar decimal number system with its 10 digits; 0,1, 2,3,4,5,6, 7, 8 and 9. these numbers are called

### CS321. Introduction to Numerical Methods

CS3 Introduction to Numerical Methods Lecture Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506-0633 August 7, 05 Number in

### Approximation Errors in Computer Arithmetic (Chapters 3 and 4)

Approximation Errors in Computer Arithmetic (Chapters 3 and 4) Outline: Positional notation binary representation of numbers Computer representation of integers Floating point representation IEEE standard

### Fast Logarithms on a Floating-Point Device

TMS320 DSP DESIGNER S NOTEBOOK Fast Logarithms on a Floating-Point Device APPLICATION BRIEF: SPRA218 Keith Larson Digital Signal Processing Products Semiconductor Group Texas Instruments March 1993 IMPORTANT

### NUMBER REPRESENTATIONS IN THE COMPUTER for COSC 120

NUMBER REPRESENTATIONS IN THE COMPUTER for COSC 120 First, a reminder of how we represent base ten numbers. Base ten uses ten (decimal) digits: 0, 1, 2,3, 4, 5, 6, 7, 8, 9. In base ten, 10 means ten. Numbers

### Using SQL Server Management Studio

Using SQL Server Management Studio Microsoft SQL Server Management Studio 2005 is a graphical tool for database designer or programmer. With SQL Server Management Studio 2005 you can: Create databases

### Paper 2917. Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA

Paper 2917 Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA ABSTRACT Creation of variables is one of the most common SAS programming tasks. However, sometimes it produces

### Binary Representation of Numbers

Binary Representation of Numbers We have discussed a simple binary positional representation of numbers. The position of each bit indicates a power of two. Consider the number 110101 (2). The powers of

### Bits, Data Types, and Operations. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

Bits, Data Types, and Operations University of Texas at Austin CS3H - Computer Organization Spring 2 Don Fussell How do we represent data in a computer? At the lowest level, a computer is an electronic

### > 2. Error and Computer Arithmetic

> 2. Error and Computer Arithmetic Numerical analysis is concerned with how to solve a problem numerically, i.e., how to develop a sequence of numerical calculations to get a satisfactory answer. Part

### Better Safe than Sorry: A SAS Macro to Selectively Back Up Files

Better Safe than Sorry: A SAS Macro to Selectively Back Up Files Jia Wang, Data and Analytic Solutions, Inc., Fairfax, VA Zhengyi Fang, Social & Scientific Systems, Inc., Silver Spring, MD ABSTRACT SAS

### Part 1 Theory Fundamentals

Part 1 Theory Fundamentals 2 Chapter 1 Information Representation Learning objectives By the end of this chapter you should be able to: show understanding of the basis of different number systems show