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

Issue in converting float16 to float32 #1163

Open
abhinav2712 opened this issue Mar 20, 2024 · 1 comment
Open

Issue in converting float16 to float32 #1163

abhinav2712 opened this issue Mar 20, 2024 · 1 comment
Labels

Comments

@abhinav2712
Copy link

I am trying to convert float16 to float32 using inbuilt functions however getting same output:

const array = new Float16Array([1.0, 1.1, 1.2, 1.3]);
  for (const value of array) {
    // 1, 1.099609375, 1.2001953125, 1.2998046875
    console.log(value);
  }
  const float32Array = new Float32Array(array.length);

  // Iterate over the Float16Array and convert each element to Float32
  for (let i = 0; i < array.length; i++) {
    float32Array[i] = array[i];
  }

  // Now float32Array contains the converted values
  console.log("f32:", float32Array);
}
@petamoriken
Copy link
Owner

It behaves as expected.

IEEE754 binary32 has a larger range of possible values than binary16, so the values are not rounded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants