On Mon, 2003-06-16 at 12:28, Federico Balbi wrote:
> Wouldn't be easier to make a call to sprintf from the C library? That
> should work fine for any case :-)

Hmmm, interesting idea.  I'm too lazy to write all the wrapper code to
convert Icon datatypes to C form, however!  (Plus printf.icn includes
some conversions not found in C's sprintf...)

> On 16 Jun 2003, Steve Wampler wrote:
> 
> >
> > Hmmm, I think the fixnum() routine has other problems in printf.icn
> > as well.  Here's another improved version, that correctly
> > handles printf("%10.7r",-0.2e-5), for example:
> > ------------------------------------------------
> > procedure fixnum(x, prec)
> >    local int, frac, f1, f2, p10
> >
> >     /prec := 6
> >     int := integer(x) | return image(x)
> >     frac := image(abs(x - int))
> >     if find("e", frac) then {
> >             frac ?:= {
> >                     f1 := ((tab(upto('.')) & move(1))|"") &
> >                     f2 := tab(upto('e')) &
> >                     move(1) &
> >                     p10 := -integer(tab(0)) &
> >                     repl("0",p10-1) || f1 || f2
> >                     }
> >             }
> >     else
> >             frac ?:= (tab(upto('.')) & move(1) & tab(0))
> >     frac := left(frac, prec, "0")
> >     if (int = 0) & (x < 0) then int := "-"||int
> >     return int || "." || frac
> > end
> > --------------------------------------------
> > Someone should probably take a close look to see if this
> > introduces other problems, though!

-- 
Steve Wampler -- [EMAIL PROTECTED]
Quantum materiae materietur marmota monax si marmota
                    monax materiam possit materiari?


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to