bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnulib] Re: base64


From: Simon Josefsson
Subject: [bug-gnulib] Re: base64
Date: Thu, 25 Nov 2004 15:24:13 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> > This is overly complex. You can also write it as
>> >    ((inlen) + 2) / 3) * 4
>>
>> I don't think that give the same result, try tabulating the two macros
>> for, say, inlen = 0...15.
>
> $ clisp
> (dotimes (inlen 16)
>   (format t "~D   ~D ~D~%" inlen
>     (+ (rem (- 4 (rem inlen 3)) 4) (truncate (* 4 inlen) 3))
>     (* (truncate (+ inlen 2) 3) 4)))
> 0   0 0
> 1   4 4
> 2   4 4
> 3   4 4
> 4   8 8
> 5   8 8
> 6   8 8
> 7   12 12
> 8   12 12
> 9   12 12
> 10   16 16
> 11   16 16
> 12   16 16
> 13   20 20
> 14   20 20
> 15   20 20
>
> Your formula also overflows needlessly when inlen in in the range
> SIZE_MAX / 4 ... 3 * SIZE_MAX / 4.

Ah, right, I'm using your version now.

Ok to install?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]