Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Icon > Re: A bug in pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 161 of 189
Post > Topic >>

Re: A bug in printf

by Cheyenne Wills <cwills@[EMAIL PROTECTED] > Sep 6, 2007 at 04:03 PM

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")
             }
          }
       }
 




 2 Posts in Topic:
A bug in printf
Cheyenne Wills <cwills  2007-09-06 12:45:15 
Re: A bug in printf
Cheyenne Wills <cwills  2007-09-06 16:03:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 18 20:34:22 CDT 2008.