[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnulib] Re: base64
From: |
Bruno Haible |
Subject: |
Re: [bug-gnulib] Re: base64 |
Date: |
Thu, 25 Nov 2004 15:06:30 +0100 |
User-agent: |
KMail/1.5 |
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.
Bruno
- [bug-gnulib] base64, Simon Josefsson, 2004/11/23
- Re: [bug-gnulib] base64, Bruno Haible, 2004/11/24
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/25
- Re: [bug-gnulib] Re: base64, Stepan Kasal, 2004/11/25
- Re: [bug-gnulib] Re: base64, Jim Meyering, 2004/11/25
- Re: [bug-gnulib] Re: base64, Stepan Kasal, 2004/11/25
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/25
- Re: [bug-gnulib] Re: base64, Stepan Kasal, 2004/11/25
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/25
- Re: [bug-gnulib] Re: base64, Bruno Haible, 2004/11/25
- Re: [bug-gnulib] Re: base64, Paul Eggert, 2004/11/26
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/26