Problem? with float()

chris hermansen clhermansen@gmail.com
Thu Mar 12 15:05:11 GMT 2026


Good morning,

On Thu, Mar 12, 2026 at 3:58 AM Jose E. Marchesi <jemarch@gnu.org> wrote:

>
> > Me again,
> >
> > On Wed, Mar 11, 2026, 15:09 Jose E. Marchesi <jemarch@gnu.org> wrote:
> >
> >>
> >> > Hello again,
> >> >
> >> > On Wed, Mar 11, 2026 at 1:25 PM Jose E. Marchesi <jemarch@gnu.org>
> >> wrote:
> >> >
> >> >>
> >> >> > Hello everyone,
> >> >> >
> >> >> > I am having a problem printing anything beyond one or more
> asterisks
> >> with
> >> >> > the float proc.
> >> >> >
> >> >> > At first I thought it was just my inexperience / ignorance, so I
> tried
> >> >> some
> >> >> > examples from McGettrick:
> >> >> >
> >> >> > begin
> >> >> >   puts(float(123.4567,12,5,2));
> >> >> >   puts("'n");
> >> >> >   puts(float(123.4567,-10,5,-1));
> >> >> >   puts("'n");
> >> >> >
> >> >> >   skip
> >> >> > end
> >> >> >
> >> >> > He suggests this should produce
> >> >> >
> >> >> > +12.34567e+1
> >> >> >  1.23457e2 (blank just in front)
> >> >> >
> >> >> > Am I missing something?  Thanks in advance!
> >> >>
> >> >>
> >> >> Hm, perhaps I got the proc wrong from the RR.  This is what we have
> >> >> right now in the standard prelude (libga68/standard.a68.in):
> >> >>
> >> >>     pub proc float = (Number v, int width, after, exp) string:
> >> >>         case v in
> >> >>            {iter L  {} {long}  {long long}}
> >> >>            {iter L_ {} {long_} {long_long_}}
> >> >>            ({L} real x):
> >> >>               if int before = ABS width - ABS exp - (after /= 0 |
> >> after+1
> >> >> | 0) - 2;
> >> >>                  SIGN before + SIGN after > 0
> >> >>               then string s, {L} real y := ABS x, int p := 0;
> >> >>                    {L_}standardize (y, before, after, p);
> >> >>                    s := fixed (SIGN (x * y), SIGN width * (ABS width
> -
> >> ABS
> >> >> exp - 1),
> >> >>                                after) + "*^" + whole (p, exp);
> >> >>                    if exp = 0 OR char_in_string (errorchar, loc int,
> s)
> >> >>                    then float (x, width, (after /= 0 | after-1 | 0),
> >> >>                                (exp > 0 | exp+1 | exp-1))
> >> >>                    else s
> >> >>                    fi
> >> >>               else { XXX undefined } skip; ABS width * errorchar
> >> >>               fi,
> >> >>            ({L} int x): float ({L} real (x), width, after, exp)
> >> >>            {reti {,}}
> >> >>         esac;
> >> >>
> >> >
> >> > A couple of things bother me above:
> >> >
> >> > I  think there's something wrong with using the same {iter L ...} to
> >> > encapsulate both real and int real parameters.  That is, I think the
> >> part:
> >> >
> >> >            ({L} int x): float ({L} real (x), width, after, exp)
> >> >            {reti {,}}
> >> >
> >> > should be wrapped separately
> >> >
> >> > {iter L {short short} {short} {} {long} {long long}}
> >> > {iter R {LENG LENG} {LENG} {} {} {}}
> >> >            ({L} int x): float ({R} real (x), width, after, exp)
> >> >            {reti {,}}
> >> > {reti {,}}
> >> >
> >> > or similar.
> >> >
> >> > Besides that, you have SIGN (x * y) and I think it should be SIGN x *
> y;
> >> at
> >> > least, that's how it's presented in the RR.
> >>
> >> Uoh, so thats a copy-pasto.
> >>
> >> Do you think we should adopt van Vliet's version rather than
> >> paraphrasing the RR?
> >>
> >
> > In principle I think so. But I should add that my opinion here isn't
> > necessarily all that valuable, because:
> >
> > 1. I don't know how many other "coat hangers" are dragged in by that,
> > 2. I haven't really looked at his versions of whole, fixed, float so I
> > don't know what we are buying with them.
>
> In fact it requires the rest of the van Vliet prelude.
>
> Do youp plan to work on the conversion routines too as part of the
> transput?
>
> If so, I will just fix the current RR-based version and at some point we
> replace the whole thing with your implementation.
>
> [stuff deleted]


I intend to keep working away at van Vliet's prelude; by which I mean at
this point trying to understand what's needed to eliminate his "pseudo"s
and otherwise a bare minimum set of changes needed to make it work.  I
believe Mountbatten and Genie provide a lot of ideas and clarity around
this topic; and that "betterments" come after a basic working
implementation.

Aside from the pleasure and satisfaction in doing this, my main motivation
is to understand how best to return to my favourite topic, implementing
those split-order lists in a way that accommodates the storage of rows and
structures, including not only values but keys (so for example that a
decent implementation of a date structure could be used as a key).

Anyway, I'm pretty certain working whole(), fixed() and float() would be
extremely useful as someone - me or another - works on van Vliet!


-- 
Chris Hermansen · clhermansen "at" gmail "dot" com

C'est ma façon de parler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/algol68/attachments/20260312/a724f99f/attachment.htm>


More information about the Algol68 mailing list