Computer Science Illuminated

eLearning
Interactive Review

Animated Flashcards
Live Wire
Cryptic Crossword Puzzles
Ethical Issues
Biographical Sketches
Did You Know?
Goin Live
Digital Lab Manual
Online Glossary
The Learning Store
Language Library
Download PEP/7
Instructor Resources
Student Resources

eLearning Home

Limitations on Value Representation

Download the Cover Sheet for this lab as an Adobe PDF. This can be used to record your answers to the questions in the lab.

The factorial of a number is the product of all the numbers between 1 and the number. The factorial of 0 is 1 by definition. Here are several examples and the general formula.

0!

1

1!

1

2!

1*2

3!

1*2*3

4!

1*2*3*4

N!

N*(N-1)

Although a very simple algorithm, the values get very large very fast. In this lesson, you will run 6 applets, each of which calculates factorials but uses a different numeric type into which to store the result.

Follow each of the links listed below and follow the instructions.


Factorial-Byte

Factorial-Short

Factorial-Int

Factorial-Long

Factorial-Float

Factorial-Double


Look carefully at the results from each of these applets. What conclusions can you draw about the size of the numbers that can be manipulated using each type of number representation? Give an example of a problem that would be appropriate for each number type.

 
Educators: More Information About This Text Other Computer Science Titles at Jones and Bartlett
Copyright 2019 Jones and Bartlett PublishersContact webmaster