Skip to content

Commit

Permalink
.with should convert value up front
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken committed Jun 26, 2022
1 parent c34d852 commit fbdb1c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Float16Array.mjs
Expand Up @@ -536,6 +536,8 @@ export class Float16Array {
const relativeIndex = ToIntegerOrInfinity(index);
const k = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;

const number = +value;

if (k < 0 || k >= length) {
throw new NativeRangeError(OFFSET_IS_OUT_OF_BOUNDS);
}
Expand All @@ -553,7 +555,7 @@ export class Float16Array {
);
const array = getFloat16BitsArray(cloned);

array[k] = roundToFloat16Bits(value);
array[k] = roundToFloat16Bits(number);

return cloned;
}
Expand Down

0 comments on commit fbdb1c8

Please sign in to comment.