english
version "1.0"
identify "xyz"

#: Copyright (c) 1996-2005 by Wayne C. Gramlich.
#, All rights reserved.

module real

#: This module implements a kludgy 64-bit floating point base type for
#, STIPPLE:

define real
    external

define real_data
    record
	buffer string
	initialized logical
	hyphen character
	lower_b character
	lower_c character
	lower_d character
	lower_digits string
	lower_h character
	lower_l character
	lower_o character
	lower_p character
	lower_s character
	lower_w character
	lower_x character
	percent character
	space character
	upper_digits string
	upper_h character
	upper_o character
	upper_x character
	zero_offset unsigned
    generate allocate, erase, print


object one@real


object zero@real



procedure add@real
    takes
	left real
	right real
    returns real
    external real__add



procedure copy@real
    takes
	arg real
    returns real
    external real__copy



procedure cosine@real
    takes
	angle real
    returns real
    external real__cosine

    #: This procedure returns the cosine of {angle}, where {angle}
    #, is measured in radians.



procedure divide@real
    takes
	left real
	right real
    returns real
    external real__divide



procedure equal@real
    takes
	left real
	right real
    returns logical
    external real__equal

    #: This procedure will return {true} if {left} is equal to {right} and
    #, {false} otherwise.  In general, it is hard to ensure that a
    #, calculation is consistent enough to ensure that two {real}'s are
    #, actually equal.



procedure float_convert@real
    takes
	real real
    returns float
    external read__float_convert

    #: This procedure will convert {real} to a {float} and return it.



procedure float_to_real@real
    takes
	float float
    returns real
    external real__float_to_real

    #: This procedure will convert {float} to {real}.



procedure format@real
    takes
	real real
	out_stream out_stream
	format string
	offset unsigned
    returns_nothing

    #: This routine will output {real} to {out_stream} using the formatting
    #, characters in {format} starting at {offset} until a terminating "%" is
    #, encountered.  See the {format} module find out more about formatted
    #, output.
    #,
    #, The accepted formats are:
    #,   b	Output a binary number.
    #,   c	Center the number.
    #,   d	Output a decimal number.
    #,   H	Output an upper-case hexadecimal number preceeded by "0X".
    #,   h	Output a lower-case hexadecimal number preceeded by "0x".
    #,   l	Left justify the number.
    #,   O	Output an octal number with a preceeding zero.
    #,   o	Output an octal number.
    #,   p<pad>	Set padding character to <pad>.
    #,   s<sep>	Separate every third digit with <sep>.
    #,   w<width> Output a minimim of <width> characters.
    #,   X	Output as an upper-case hexadecimal number.
    #,   x	Output as a lower-case hexadecimal number.

    #, Scan the format characters:

procedure greater_than@real
    takes
	left real
	right real
    returns logical
    external real__greater_than



procedure hash@real
    takes
	arg real
    returns unsigned
    external real__hash



procedure input@real
    takes
	input in_stream
    returns real

procedure less_than@real
    takes
	left real
	right real
    returns logical
    external real__less_than



procedure minus@real
    takes
	arg real
    returns real
    external real__minus



procedure multiply@real
    takes
	left real
	right real
    returns real
    external real__multiply



procedure output@real
    takes
	real real
	output out_stream
    returns_nothing

procedure parse@real
    takes
	input in_stream
    returns real

procedure print@real
    takes
	real real
	out_stream out_stream
    returns_nothing

    #: This procedure will print {real} as a decimal number to
    #, {out_stream}.


procedure put@real
    takes
	real real
	out_stream out_stream
    returns_nothing

procedure power@real
    takes
	left real
	right real
    returns real
    external real__power



procedure random_compute@real
    takes_nothing
    returns real

    #: This procedure returns a random number.


procedure remainder@real
    takes
	left real
	right real
    returns real
    external real__remainder



procedure save@real
    takes
	real real
	save save
	offset unsigned
    returns_nothing

    # save[offset] := real@(save, real)



procedure set_set@real
    takes
	left real
	right real
    returns_nothing
    external real__set_set



procedure sine@real
    takes
	angle real
    returns real
    external real__sine

    #: This procedure returns the sine of {angle}, where {angle}
    #, is measured in radians.



procedure square_root@real
    takes
	arg real
    returns real
    external real__square_root

    #: This procedure returns the square root of {arg}.



procedure subtract@real
    takes
	left real
	right real
    returns real
    external real__subtract



procedure unsigned_convert@real
    takes
	arg real
    returns unsigned
    external real__unsigned_convert



procedure real_convert@unsigned
    takes
	arg unsigned
    returns real
    external unsigned__real_convert