|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] base64 byte-length formula
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: Sun Jun 30 02:19:01 2002 11024 messages in chronological order |