

            gltoc (2) --- convert double precision integer to any radix string  03/23/80


            _C_a_l_l_i_n_g _I_n_f_o_r_m_a_t_i_o_n

                 integer function gltoc (int, str, size, base)
                 long_int int
                 integer size, base
                 character str (size)

                 Library:  vswtlb (standard Subsystem library)


            _F_u_n_c_t_i_o_n

                 'Gltoc'  will convert a double precision (32 bit) integer to
                 a character string representation in any radix from 2 to  16
                 (inclusive).   The integer to be converted may be considered
                 as either a signed, two's-complement number with 31 bits  of
                 precision,  or  as  an  unsigned  number  with  32  bits  of
                 precision.

                 'Int' is the integer to be converted; 'str' is  a  character
                 array  into  which the string representation will be stored;
                 'size' is the size of 'str'.  The absolute value  of  'base'
                 is  the conversion radix.  If 'base' is negative, then 'int'
                 is treated  as  an  unsigned  number;  otherwise,  'int'  is
                 considered  to be a signed, two's-complement number.  If the
                 specified radix is not in the range  2:16,  then  a  decimal
                 conversion is performed.

                 For  a  signed conversion, if the integer is less than zero,
                 its absolute value is preceded by a minus sign in  the  con-
                 verted  string;  a  positive  number  is never preceded by a
                 sign.

                 The function return is the number of characters required  to
                 represent the integer.


            _I_m_p_l_e_m_e_n_t_a_t_i_o_n

                 'Gltoc'  uses  a  typical  divide-and-remainder algorithm to
                 perform the conversion; that is, a  digit  is  generated  by
                 taking  the  remainder  when  the  integer is divided by the
                 radix.  For signed conversions, the absolute  value  of  the
                 number  is  first taken, the digits generated, and the minus
                 sign inserted if  needed.   For  unsigned  conversions,  the
                 least  significant  bit of the number is saved, and then the
                 number is shifted right one bit position to put it into  the
                 precision  range  of  31  bits (and effectively dividing the
                 unsigned number  by  2).   Then,  as  each  digit  value  is
                 generated,  it  is  doubled  and added to the carry from the
                 previous digit position (with the initial  carry  being  the
                 saved  least  significant  bit)  and  a  new  carry value is
                 generated.





            gltoc (2)                     - 1 -                     gltoc (2)




            gltoc (2) --- convert double precision integer to any radix string  03/23/80


            _A_r_g_u_m_e_n_t_s _M_o_d_i_f_i_e_d

                 str


            _S_e_e _A_l_s_o

                 gitoc (2), ltoc (2), other conversion routines ('cto?*'  and
                 '?*toc') (2)

















































            gltoc (2)                     - 2 -                     gltoc (2)


