On Mon, 2003-06-16 at 11:04, Steve Wampler wrote:
> On Mon, 2003-06-16 at 10:52, yhou4 wrote:
> > I use sprintf to convert float to string. The program is like below,
> >
> > link printf
> >
> > procedure main()
> > k:= -0.833333333333
> >
> > m:= sprintf("%.5r",k)
> > write(m)
> > end
> >
> > But I found the output is 0.83333.
> > Why it lose the minus sign? The book said "r" format is for the real numbers.
> >
>
> That is a bug in printf.icn's fixnum() procedure! Here's one
> way to fix the problem - there's probably a better way:
>
> In ipl/procs/printf.icn, in the procedure fixnum(x, prec),
> change the last few lines from:
> ------------------------------------------------------
> frac := left(frac, prec, "0")
> return int || "." || frac
> end
> ------------------------------------------------------
> to:
Sigh - that fix is bad. Here's a better one!
> ------------------------------------------------------
> frac := left(frac, prec, "0")
> if (int = 0) & (x < 0) then int := "-"||int
> return int || "." || frac
> end
> ------------------------------------------------------
>
> (The problem is that integer("-0.1234") is 0...)
--
Steve Wampler -- [EMAIL PROTECTED]
Quantum materiae materietur marmota monax si marmota
monax materiam possit materiari?
-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group