Add missing docstrings (#5168)
Co-authored-by: Ernesto García <ernestognw@gmail.com>
This commit is contained in:
@ -40,14 +40,17 @@ library Base64 {
|
||||
|
||||
// If padding is enabled, the final length should be `bytes` data length divided by 3 rounded up and then
|
||||
// multiplied by 4 so that it leaves room for padding the last chunk
|
||||
// - `data.length + 2` -> Round up
|
||||
// - `/ 3` -> Number of 3-bytes chunks
|
||||
// - `data.length + 2` -> Prepare for division rounding up
|
||||
// - `/ 3` -> Number of 3-bytes chunks (rounded up)
|
||||
// - `4 *` -> 4 characters for each chunk
|
||||
// This is equivalent to: 4 * Math.ceil(data.length / 3)
|
||||
//
|
||||
// If padding is disabled, the final length should be `bytes` data length multiplied by 4/3 rounded up as
|
||||
// opposed to when padding is required to fill the last chunk.
|
||||
// - `4 *` -> 4 characters for each chunk
|
||||
// - `data.length + 2` -> Round up
|
||||
// - `/ 3` -> Number of 3-bytes chunks
|
||||
// - `4 * data.length` -> 4 characters for each chunk
|
||||
// - ` + 2` -> Prepare for division rounding up
|
||||
// - `/ 3` -> Number of 3-bytes chunks (rounded up)
|
||||
// This is equivalent to: Math.ceil((4 * data.length) / 3)
|
||||
uint256 resultLength = withPadding ? 4 * ((data.length + 2) / 3) : (4 * data.length + 2) / 3;
|
||||
|
||||
string memory result = new string(resultLength);
|
||||
|
||||
Reference in New Issue
Block a user