[comp.lang.fortran] FLOAT <-> CHARACTER

jy0q+@andrew.cmu.edu (Jules Andrew Yasuna) (06/14/90)

Does anyone have access to subroutines/functions which will
convert floating point variables to and from character variables.
The essence of such a code is not all too involved { INDEX(), CHAR(),
ICHAR(), etc. along with some knowledege os ASCII codes } yet
implementation, namely bookeeping, tends to be quite tedious.

If anyone has developed such routines (personal or Public Domain) and
is willing to share them, I would be most grateful !!

Thanks in advance ....

buckland@cheddar.ucs.ubc.ca (Tony Buckland) (06/14/90)

In article <waRt4sW00WB4QGKEw4@andrew.cmu.edu> jy0q+@andrew.cmu.edu (Jules Andrew Yasuna) writes:
>
>Does anyone have access to subroutines/functions which will
>convert floating point variables to and from character variables.
 
 You don't say why you want to make these conversions.  But if you
 just want to put the external character representation of a
 floating-point quantity in a character variable or array, the
 simplest way is to use internal input/output (assuming that your
 compiler implements Internal WRITE and Internal READ).

pfennige@uni2a.unige.ch (06/15/90)

In article <waRt4sW00WB4QGKEw4@andrew.cmu.edu>, jy0q+@andrew.cmu.edu (Jules Andrew Yasuna) writes:
> Does anyone have access to subroutines/functions which will
> convert floating point variables to and from character variables.
> The essence of such a code is not all too involved { INDEX(), CHAR(),
> ICHAR(), etc. along with some knowledege os ASCII codes } yet
> implementation, namely bookeeping, tends to be quite tedious.
> 
> If anyone has developed such routines (personal or Public Domain) and
> is willing to share them, I would be most grateful !!
> 
        These possibilities are included in Fortran:
------------
        character*15 cnumber
        real x
        ...
c   conversion real -> character
        x = 1.23456
        write(cnumber,*) x
        ...
c   conversion character -> real
        cnumber = '9.87654'
        read (cnumber,*) x
        ...
-------------
The * can be replaced by any FORMAT of course.  

	Dan