
FPLIB	A set of routines for some floating point functions

The original routines were obtained from a BBS many years ago and it possibly
originates from Microsoft. Following my interest in Win32 I have converted 
the source to work under Win32 and made some alterations, mainly to FTOA
where I have provided a means of setting the number of decimal places
in the displayed ASCII output for the given floating point number. Also ATOF
now returns ax with any detected faulty character in the low byte and its
position in the word in the high byte, thereby providing a means of checking
input for those "O" for "0" and "I" for "1"  and other miskeys which always seem
to occur.

As the routines use 32 bit floating point arithmetic the precision is 
limited to 6 to 7 digits, but this should be more than enough for most graphics
programs. If I get enough requests I will consider upgrading to 64 bit arithmetic
which will provide a precision of 15 to 16 digits.

The program TestFP is provided as an example of the use of ATOF and FTOA
It also incidentally shows how to access and use some of the trigometric functions
such as sine, cosine and tangent. If you want examples of the use of ROTATE take
a look at demos CLOCK and MIRRORS which are available on my web site.  

To use the library place it in MASM32\LIB folder and it will then resolve the
floating point subroutines when you link.


Ron Thomas 4/12/99

;---------------------------------------------------------------;
; ATOF.ASM ---  Convert ASCII String to Binary 			;
;               Floating Point Number on 80x87 Stack		;
;               (also requires FALOG from FALOG.ASM)		;	
;								;	
; Call with:	SI = address of string in the form		;
;		[sign][digits][.[digits]][E|e[sign][exp]]	;
;		leading blanks or tabs are ignored		;
;								;
; Returns:      ST(0) = binary floating point value		;
;               SI = address+1 of terminator 			;
;		ax	(low byte) faulty character		;
;			(high byte) position from start		; 
;								;
; This routine gives no warning in the event of 		;
; overflow, and terminates on the first invalid character.	;
;								;
; Coprocessor should be initialised before call			;
;---------------------------------------------------------------;

;-------------------------------------------------------;
; FTOA.ASM ---  Convert Binary Floating Point		;
;               Number on 80x87 Stack to ASCII          ;	        
;               (also requires FALOG from FALOG.ASM)	;
;							;
; Call with:    ST(0) = floating point number		;
;               SI = buffer to receive string		;	
;							;
;		eax   = No of digits after the decimal	;
;							;
; Returns:      SI = address of converted string	;
;               AX    = length of string		;
;               Coprocessor stack "popped"		;
;							;
; Note1: The number of digits after the decimal can at	;
;	present only be an even number, between 2 & 18  ;
;	Odd numbers are rounded down.			;
;							;
; Note2: As we use short REAL4 or 32 bits, the precision;
;        is effectively 6 to 7 digits. This could be 	;
;	 improved to 15-16 if we change the code to use ;
;	 long real, REAL8 (64 bits). As present its 	;
;	 probably adequate for most graphics functions	;

; Coprocessor should be initialised before call		;
;-------------------------------------------------------;

;Falog
;-------------------------------------------------------;
; Calculate Common Antilog on 80x87			;
;							;
; Call  :    st(0)     = logarithm (base 10)		;
;							;	
; Return:    st(0)     = antilog to base 10		;
;							;
; Coprocessor should be initialised before call		;
;-------------------------------------------------------;

;Rotate
;---------------------------------------------------------------;
; This routine finds new values for cartesian coordinates X & Y	;
; when the point is rotated by theta degrees			;
;								;
; Enter: SI points at a data block in the calling routine	;
;								;
;	  [si] (real4) contains the rotation angle in degrees	;
;	[si+4] (real4) contains the math X coordinate		;
;	[si+8] (real4) contains the math Y coordinate		;     	   
;	[si+12](real4) will contain the new X coordinate	;
;	[si+16](real4) will contain the new Y coordinate	;
;								;
; Note: I keep the orignal coords (as opposed to updating	;
;	so that a program can reuse the same values if required	;
;								; 		  														;
;	X1 =  X * cos(theta)  +  Y * sin(theta) 		;
;	Y1 = -X * sin(theta)  +  Y * cos(theta)			;
; 								;
; Return:  New coords are updated in callers parameter block.	;  
;---------------------------------------------------------------;

