Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 17 in printed book and digital formats -- plus a one-year subscription (beginning with 18.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 3.6

FEATURE

Floating Numbers

The Problem with Floating-Point Numbers, Part I

Issue: 3.6 (July/August 2005)
Author: William H. Murray and Chris H. Pappas
Author Bio: Murray and Pappas are department chairmen of the Electrical Engineering Technology and Computer Studies programs, respectively, at Broome Community College which is a S.U.N.Y. system college in upstate New York. Murray and Pappas have written over 50 trade books on assembly language, C, C++, C#, Java, Windows, and more.
Article Description: No description available.
Article Length (in bytes): 27,698
Starting Page Number: 22
Article Number: 3611
Related Link(s): None

Excerpt of article text...

You have grown up using generations of computers that allow the use of both integer and real numbers. Integer arithmetic, by its very nature, is precise as long as the computer system can handle the number of bits required to represent the integer results. Real number arithmetic, on the other hand, has the potential of suffering from precision and rounding errors at every turn.

In the mid-80's, the American National Standards Institute (ANSI) and the Institute for Electrical and Electronic Engineers (IEEE) released the ANSI/IEEE 754 floating-point standard. It addresses many of the issues dealing with real numbers and how they might be represented in order to contain precision and rounding errors.

Fortunately for programmers, all modern programming languages -- including REALbasic -- implement this standard in their float-point arithmetic. As long as the compiler developers of a computer language get the implementation of the ANSI/IEEE standard right, the user is completely isolated from the process.

However, if you want to know what is really going on in your computer in terms of integers and real numbers, you will have to leave your compiled languages and seek help at the machine code or assembly language code level. At that level, you'll find different data types and different instructions for performing integer and floating-point arithmetic. Remember, this is something that is handled automatically in high-level languages.

So, why would anyone care about this problem at all if it is handled automatically by the compiler? First, how much confidence do you have that the compiler developer got it right? Are you confident enough to stake your $500,000 mortgage payments on it? Secondly, if you ever have to develop your own tools for a language you are creating or a language you are modifying, you are going to have to find a way to implement this floating-point standard.

The problem with the data bus

...End of Excerpt. Please purchase the magazine to read the full article.