TOC PREV NEXT INDEX

Webster Home Page



11.4 HLA Standard Library Support for Floating Point Arithmetic

The HLA Standard Library provides several routines that support the use of real number on the FPU. In Volume One you saw, with one exception, how the standard input and output routines operate. This section will not repeat that discussion, see "HLA Support for Floating Point Values" on page 93 for more details. One input function that Volume One only mentioned briefly was the stdin.getf function. This section will elaborate on that function. The HLA Standard Library also includes the "math.hhf" module that provides several mathematical functions that the FPU doesn't directly support. This section will discuss those functions, as well.

11.4.1 The stdin.getf and fileio.getf Functions

The stdin.getf function reads a floating point value from the standard input device. It leaves the converted value in ST0 (i.e., on the top of the floating point stack). The only reason Chapter Two did not discuss this function thoroughly was because you hadn't seen the FPU and FPU registers at that point.

The stdin.getf function accepts the same inputs that "stdin.get( fp_variable );" would except. The only difference between the two is where these functions store the floating point value.

As you'd probably surmise, there is a corresponding fileio.getf function as well. This function reads the floating point value from the file whose file handle is the single parameter in this function call. It, too, leaves the converted result on the top of the FPU stack.

11.4.2 Trigonometric Functions in the HLA Math Library

The FPU provides a small handful of trigonometric functions. It does not, however, support the full range of trig functions. The HLA MATH.HHF module fills in most of the missing functions. The trigonometric functions that HLA provides include

The HLA Standard Library actually provides five different routines you can call for each of these functions. For example, the prototypes for the first four COT (cotangent) routines are:

		procedure cot32( r32: real32 );
 
		procedure cot64( r64: real64 );
 
		procedure cot80( r80: real80 );
 
		procedure _cot();
 

 

The first three routines push their parameter onto the FPU stack and compute the cotangent of the result. The fourth routine above (_cot) computes the cotangent of the value in ST0.

The fifth routine is actually an overloaded procedure that calls one of the four routines above depending on the parameter. This call uses the following syntax:

		cot();				// Calls _cot() to compute cot(ST0).
 
		cot( r32 );				// Calls cot32 to compute the cotangent of r32.
 
		cot( r64 );				// Calls cot64 to compute the cotangent of r64.
 
		cot( r80 );				// Calls cot80 to compute the cotangent of r80.
 

 

Using this fifth form is probably preferable since it is much more convenient. Note that there is no efficiency loss when you used cot rather than one of the other cotangent routines. HLA actually translates this statement directly into one of the other calls.

The HLA trigonometric functions that require an angle as a parameter expect that angle to be expressed in radians, not degrees. Keep in mind that some of these functions produce undefined results for certain input values. If you've enabled exceptions on the FPU, these functions will raise the appropriate FPU exception if an error occurs.

11.4.3 Exponential and Logarithmic Functions in the HLA Math Library

The HLA MATH.HHF module provides several exponential and logarithmic functions in addition to the trigonometric functions. Like the trig functions, the exponential and logarithmic functions provide five different interfaces to each function depending on the size and location of the parameter. The functions that MATH.HHF supports are

Except for the YtoX function, all these functions provide the same sort of interface as the cot function mentioned in the previous section. For example, the exp function provides the following prototypes:

		procedure exp32( r32: real32 );
 
		procedure exp64( r64: real64 );
 
		procedure exp80( r80: real80 );
 
		procedure _exp();
 

The exp function, by itself, automatically calls one of the above functions depending on the parameter type (and presence of a parameter):

		exp();				// Calls _exp() to compute exp(ST0).
 
		exp( r32 );				// Calls exp32 to compute the e**r32.
 
		exp( r64 );				// Calls exp64 to compute the e**r64.
 
		exp( r80 );				// Calls exp80 to compute the e**r80.
 

 

The lone exception to the above is the YtoX function. YtoX has its own rules because it has two parameters rather than one (Y and X). YtoX provides the following function prototypes:

		procedure YtoX32( y: real32; x: real32 );
 
		procedure YtoX64( y: real64; x: real64 );
 
		procedure YtoX80( y: real80; x: real80 );
 
		procedure _YtoX();
 

 

The _YtoX function computes ST1**ST0 (i.e., ST1 raised to the ST0 power).

The YtoX function provides the following interface:

		YtoX();						// Calls _YtoX() to compute exp(ST0).
 
		YtoX( y32, x32);						// Calls YtoX32 to compute y32**x32.
 
		YtoX( y64, x64 );						// Calls YtoX64 to compute y64**x64.
 
		YtoX( y80, x80 );						// Calls YtoX80 to compute y80**x80.
 

Web Site Hits Since
Jan 1, 2000

TOC PREV NEXT INDEX