Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove no longer used float2MantissaExponent internal function #7130

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/core/math/float-packing.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,6 @@ class FloatPacking {
value = math.clamp((value - min) / (max - min), 0, 1);
FloatPacking.float2Bytes(value, array, offset, numBytes);
}

/**
* Packs a float into specified number of bytes, using 1 byte for exponent and the remaining
* bytes for the mantissa.
*
* @param {number} value - The float value to pack.
* @param {Uint8ClampedArray} array - The array to store the packed value in.
* @param {number} offset - The start offset in the array to store the packed value at.
* @param {number} numBytes - The number of bytes to pack the value to.
*
* @ignore
*/
static float2MantissaExponent(value, array, offset, numBytes) {
// exponent is increased by one, so that 2^exponent is larger than the value
const exponent = Math.floor(Math.log2(Math.abs(value))) + 1;
value /= Math.pow(2, exponent);

// value is now in -1..1 range, store it using specified number of bytes less one
FloatPacking.float2BytesRange(value, array, offset, -1, 1, numBytes - 1);

// last byte for the exponent (positive or negative)
array[offset + numBytes - 1] = Math.round(exponent + 127);
}
}

export { FloatPacking };