Previous page Next page Navigation bar

Calculator Programming Tutorial

Programming Building Blocks I

Fundamental Data Types

Computers and computer programs manipulate data: that is their reason for being. It makes sense, therefore, to wonder what characterizes “data.”

Computers are finite constructions, and so any given datum is itself finite: there are a finite (although perhaps large) number of values the datum can take on. A floating point number might be, for example, a value with ten significant digits and a two digit exponent. An integer number might be, for example, a value between 32768 and 32767, inclusive. A character might be, for example, any of a letter (such as “a” or “A”), a digit (such as “0” or “9”), a punctuation mark (such as “.” or “-”), or a special character (such as “start of heading” or “end of text”). Data types such as these are generally provided by the computer or language itself, and are called atomic, primitive, or fundamental types. Other types, built out of combinations of these fundamental types, are called aggregate types.

Calculator Data Types

The Casio FX-7400G defines only one type, a number with 15 significant digits and two exponent digits. This can hold values between 1×10-99 and 9.99999999999×1099 in absolute value, and zero. Note that while the calculator carries 15 significant digits, 12 digits should be regarded as the limit of significance. The calculator uses ranges of values of the last three digits to determine whether a number should be treated as if it were a nearby number with special properties. For example, 1/3 has no exact finite decimal equivalent, and the calculator computes this as 0.333333333333333 — the closest approximation the calculator can hold. Three times this is 0.999999999999999, but the calculator computes the product as exactly 1: the calculator decides the answer “intended” is 1.

The Casio CFX-9850G defines two types. The first is a numeric type identical to the type defined by the FX-7400G. The second is a complex variant of that type. Each complex number is a+bi, where a and b are values of the first numeric type, and i is the square root of negative 1. The 9850 in fact uses these complex numbers for almost all computations. The real numbers are used only for list and matrix elements. However, that the calculator is usually manipulating complex numbers is not apparent. The only common operation on real numbers that typically can yield a complex number is the square root operation.

Visual Basic for Applications Data Types

The Visual Basic for Applications language has a number of fundamental types, of which the following are the most important for the purposes of this tutorial:

Type

Description

Boolean

A type capable of holding two values, False and True

Double

A numeric data type capable of holding values between 4.94065645841247×10-324 and 1.79769313486232×10308 in absolute value, and zero

Long

A numeric data type capable of holding integer values between 2147482648 and 2147483647, inclusive

String

A type capable of holding strings, that is, ordered sequences of characters of essentially arbitrary length

VBA also has Byte, Currency, Decimal, Date, Integer, Single, fixed-length String, Variant, and Object as fundamental types. These are of critical importance in most applications, but are ignored here as we will not use them.

JavaScript Types

The JavaScript language defines three fundamental types, as follows:

Type

Description

Boolean

A type capable of holding two values, False and True

Number

A numeric data type capable of holding values between 4.94065645841247×10-324 and 1.79769313486232×10308 in absolute value, and zero

String

A type capable of holding strings, that is, ordered sequences of characters of essentially arbitrary length

Although JavaScript defines these three types, variables cannot be restricted to holding objects of a single type, and JavaScript will generally convert values from one type to another at need. Thus, while these types exist, JavaScript is essentially untyped. JavaScript variables and expressions act similarly to variables and expressions of the Variant type of VBA.

Aggregate Types

All of JavaScript, Visual Basic for Applications, and the calculators define what are called aggregate types — values made up of other values. These will be covered in the section Data Structures I.

[ Previous page | Top of page | Next page ]

Previous page Top of page Next page Navigation bar

Copyright © 2001 Brian Hetrick
Page last updated 30 December 2001.

Brian’s Casio Calculator Corner

Home

Programs

Tutorial

Preface

Introduction

Fundamentals

Building Blocks I

Introduction

Comments

Data Types

Numbers

Variables

Expressions

Control Flow I

Control Flow II

Subprograms

Basic I/O

Algorithms

A First Program

Examples

Exercises

Answers

Modularization

Data Structures I

Recursion

Program Attributes

Building Blocks II

Algorithm Analysis

Structuring

Data Structures II

Abstract Types

Objects

Problem Analysis

Reference Card

References

Puzzles

Site Information

Your Privacy

Site Map

E-mail

Site Technical Data