On Thu, 06 Sep 2007 12:45:15 +0000, Cheyenne Wills wrote:
> I found a little bug hidden in the printf function in the IPL. It drops
> leading zeros to the right of the decimal point.
>
> The following code illustrates the problem ----[printfbug.icn]----
> link printf
> procedure main()
> a := 0.00114
> printf("%.4r\n",a)
> a := 0.00115
> printf("%.4r\n",a)
> end
> ----[eof]----
>
> running it produces ->
>
> 0.0011
> 0.1200
>
> ----
>
> I will work up a fix this evening when I get back home.
>
> Cheyenne Wills
Looks like it might be a fairly simple fix -- I need to run some more
tests, but this at an initial glance seems to fix the problem.
--- /usr/lib/icon/ipl/procs/printf.icn 2006-12-07 17:38:32.000000000
-0700
+++ printf.icn 2007-09-06 09:43:20.000000000 -0600
@[EMAIL PROTECTED]
-305,7 +305,7 @[EMAIL PROTECTED]
procedure adjustfracprec(fracpart, prec)
# fractional part. (We put back any trailing
# zeros that got lost.)
else {
- fracpart := left(integer(fracpart)+1, prec, "0")
+ fracpart := right(integer(fracpart)+1, prec, "0")
}
}
}


|