|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: base64 byte-length formulaSorry - It must have stayed in my pile. Your formula is not correct. The correct one is (n*3 + 3)/4 Julo
I don't particularly care, but the formula given on page 71 of 12-98 is wrong (and I've mentioned it a few times already). A very simple counterexample: 0 base64 digits should result in a 0-byte binary string. According to the given formula, floor((0 + 3) * 3 / 4) - 0) = 2. Another, more realistic but just as simple one: 4 base64 digits should result in a 3-byte binary string. According to the given formula, floor((4 + 3) * 3 / 4) - 0) = 5. The given formula also fails for n = 3 (mod 4). The correct formula, IMO is the following: floor(n * 3 / 4). In other words, there is no need to even count the equivalence signs at the end, nor to add any constants. Martins Krikis, Intel Corp. Disclaimer: these opinions are mine and may not be my employer's. __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
Home Last updated: Wed Jun 12 19:18:45 2002 10734 messages in chronological order |