Email list hosting service & mailing list manager

Bug in srfi-48? Donald Allen (11 Oct 2017 19:42 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (11 Oct 2017 19:46 UTC)
Re: Bug in srfi-48? Donald Allen (11 Oct 2017 20:36 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (11 Oct 2017 21:33 UTC)
Re: Bug in srfi-48? Donald Allen (12 Oct 2017 13:04 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (12 Oct 2017 19:07 UTC)
Re: Bug in srfi-48? Donald Allen (12 Oct 2017 19:42 UTC)
Re: Bug in srfi-48? Shiro Kawai (12 Oct 2017 20:40 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (12 Oct 2017 23:13 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 02:09 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 15:58 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 16:13 UTC)
Re: Bug in srfi-48? Marc Feeley (13 Oct 2017 17:50 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 17:52 UTC)
Re: Bug in srfi-48? Shiro Kawai (13 Oct 2017 19:54 UTC)
Re: Bug in srfi-48? John Cowan (13 Oct 2017 17:34 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 17:51 UTC)
Re: Bug in srfi-48? Alex Shinn (14 Oct 2017 13:03 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (14 Oct 2017 13:11 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (18 Oct 2017 18:20 UTC)
Re: Bug in srfi-48? Donald Allen (18 Oct 2017 19:11 UTC)

Re: Bug in srfi-48? Marc Feeley 13 Oct 2017 17:51 UTC

I’ve found this code works well for me…

(define (num->string num w d) ; w = total width, d = decimals
 (let ((n (round (* (abs (inexact->exact num)) (expt 10 d)))))
   (let ((i (quotient n (expt 10 d)))
         (f (modulo n (expt 10 d))))
     (let ((si (string-append
                 (if (< num 0) "-" "")
                 (number->string i 10)))
           (sf (if (> d 0)
                   (let ((sf (number->string (+ f (expt 10 d)) 10)))
                     (string-set! sf 0 #\.)
                     sf)
                   "")))
       (let ((lsi (string-length si))
             (lsf (string-length sf)))
         (let ((blanks (- w (+ lsi lsf))))
           (string-append (make-string (max blanks 0) #\space) si sf)))))))

Perhaps that’s better for your purpose than srfi-48.

Marc

> On Oct 13, 2017, at 12:13 PM, Donald Allen <xxxxxx@gmail.com> wrote:
>
> Here's another:
>
>> (load "srfi-48.scm")
> "/home/dca/Software/newcash/gLibraries/srfi-48/srfi-48.scm"
>> (format "~8,0F" -14.99995999999362)
> "    -13."
>> (round -14.99995999999362)
> -15.
>>
>
> The version of srfi-48.scm I am using has both of yesterday's patches
> installed. I saw the symptoms of the above before installing these
> patches, so I don't think they are the cause of this error.
>
> On 13 October 2017 at 11:58, Donald Allen <xxxxxx@gmail.com> wrote:
>> The patches offered thus far seem to have addressed the problems I
>> previously reported. But here's another:
>>
>> 1> (format "~7,2F" 18.0000000000008)
>> "  18.0."
>> 1>
>>
>> And I am seeing symptoms in my application that other numbers are not
>> being displayed correctly. I have not chased them down yet, but will
>> try to do so and report if I find anything.
>>
>> I must say that it's disconcerting to be finding all these problems in
>> code that was finalized in 2004. I think at the very least, a warning
>> should be posted in an appropriate place that issues have been found
>> with this srfi, efforts are being made to correct them, and until
>> further notice, its use may not produce correct results.
>>
>> /Don
>>
>> On 12 October 2017 at 22:09, Donald Allen <xxxxxx@gmail.com> wrote:
>>> On 12 October 2017 at 19:13, Arthur A. Gleckler <xxxxxx@speechcode.com> wrote:
>>>> On Thu, Oct 12, 2017 at 12:42 PM, Donald Allen <xxxxxx@gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>> Sorry, I wasn't clear. I was talking about this:
>>>>
>>>>
>>>> I apologize.  That should have been obvious to me.  I've been trying to do
>>>> too many things at once over the past few days.
>>>>
>>>> Would you mind trying Shiro Kawai's patch?
>>>
>>> I applied both yours and Shiro Kawai"s patches:
>>>
>>> 1>  (format "~a & ~7,2F\\%\\\\\n" "Framingham Mass Muni Purpose Loan"
>>> 1.997554209949891)
>>> "Framingham Mass Muni Purpose Loan &    2.00\\%\\\\\n"
>>> 1>  (format "~a & ~7,2F\\%\\\\\n" "Framingham Mass Muni Purpose Loan"
>>> .997554209949891)
>>> "Framingham Mass Muni Purpose Loan &    1.00\\%\\\\\n"
>>> 1> (format "~7,2F" .997554209949891)
>>> "   1.00"
>>> 1> (format "~7,2F" .99755420)
>>> "   1.00"
>>> 1> (format "~7,2F" .99755)
>>> "   1.00"
>>> 1> (format "~7,2F" .997)
>>> "   1.00"
>>> 1> (format "~7,2F" .99)
>>> "    .99"
>>> 1>
>>>
>>> Looks good. Thanks very much.
>>>
>>> /Don
>>>
>>>>
>>>> (Thank you, Mr. Kawai.)

Marc