english
version "1.0"
identify "%Z%%M% %I% %E%"

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

module integer

#: This module implements the 32-bit signed integer base type for STIPPLE:

define integer
    external

define integer_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@integer

object zero@integer


procedure absolute@integer
    takes
	arg integer
    returns integer
    #: This procedure will return the absolute value of {arg}


procedure add@integer
    takes
	left integer
	right integer
    returns integer
    external integer__add



procedure and@integer
    takes
	left integer
	right integer
    returns integer
    external integer__and



procedure buffer_append@integer
    takes
	arg integer
	buffer string
    returns_nothing

    #: This procedure will append {arg} to {buffer} as a signed
    #, decimal integer.


procedure buffer_append_helper@integer
    takes
	arg integer
	buffer string
    returns_nothing

    #: This procedure will recursively append {arg} to {buffer} as
    #, a signed decimal inteer.


procedure character_convert@integer
    takes
	arg integer
    returns character
    external integer__character_convert

    #: This procedure will convert {arg} into its corresponding character.




procedure copy@integer
    takes
	arg integer
    returns integer
    external integer__copy



procedure divide@integer
    takes
	left integer
	right integer
    returns integer
    external integer__divide



procedure equal@integer
    takes
	left integer
	right integer
    returns logical
    external integer__equal



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

    #: This routine will output {integer} 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@integer
    takes
	left integer
	right integer
    returns logical
    external integer__greater_than



procedure hash@integer
    takes
	arg integer
    returns unsigned
    external integer__hash



procedure input@integer
    takes
	input in_stream
    returns integer

procedure is_negative@integer
    takes
	integer integer
    returns logical
    external integer__is_negative



procedure left_shift@integer
    takes
	left integer
	right integer
    returns integer
    external integer__left_shift



procedure less_than@integer
    takes
	left integer
	right integer
    returns logical
    external integer__less_than



procedure maximum@integer
    takes
	left integer
	right integer
    returns integer
    #: This procedure will return the maximum of {left} and {right}.


procedure minimum@integer
    takes
	left integer
	right integer
    returns integer
    #: This procedure will return the minimum of {left} and {right}.


procedure minus@integer
    takes
	arg integer
    returns integer
    external integer__minus



procedure multiply@integer
    takes
	left integer
	right integer
    returns integer
    external integer__multiply



procedure not@integer
    takes
	arg integer
    returns integer
    external integer__not	



procedure output@integer
    takes
	arg integer
	output out_stream
    returns_nothing

procedure or@integer
    takes
	left integer
	right integer
    returns integer
    external integer__or



procedure parse@integer
    takes
	input in_stream
    returns integer

procedure print@integer
    takes
	integer integer
	out_stream out_stream
    returns_nothing

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


procedure put@integer
    takes
	integer integer
	out_stream out_stream
    returns_nothing

procedure power@integer
    takes
	left integer
	right integer
    returns integer
    external integer__power



procedure remainder@integer
    takes
	left integer
	right integer
    returns integer
    external integer__remainder



procedure right_shift@integer
    takes
	left integer
	right integer
    returns integer
    external integer__right_shift



procedure save@integer
    takes
	integer integer
	save save
	offset unsigned
    returns_nothing


procedure string_convert@integer
    takes
	arg integer
    returns string

    #: This procedure will convert {arg} into a signed decimal string
    #, and return it.


procedure subtract@integer
    takes
	left integer
	right integer
    returns integer
    external integer__subtract



procedure unsigned_convert@integer
    takes
	integer integer
    returns unsigned
    external integer__unsigned_convert



procedure xor@integer
    takes
	left integer
	right integer
    returns integer
    external integer__xor