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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for Float16Array #3828

Closed
bakkot opened this issue May 16, 2023 · 1 comment 路 Fixed by #4017
Closed

Tests for Float16Array #3828

bakkot opened this issue May 16, 2023 · 1 comment 路 Fixed by #4017

Comments

@bakkot
Copy link
Contributor

bakkot commented May 16, 2023

The Float16Array proposal is now stage 3 (馃帀). That means it's time for tests! Here's the things which occur to me offhand; feel free to edit this issue to add more.

  • the usual tests around property descriptors etc
  • rounding behavior (for Float16Array instances as well as for the DataView methods and for f16round), including at least the following cases:
    • 0, NaN, Infinity
    • the largest finite double which is precisely representable as a float16: 65504
    • the smallest integral double which is not precisely representable as a float16: 2049
    • the smallest double which is precisely representable as a non-subnormal float16: 0.00006103515625
    • the largest double which is precisely representable as a subnormal float16: 0.000060975551605224609375
    • the smallest double which is precisely representable precisely as a float16: 0.000000059604644775390625
    • the largest double which rounds to 0 when cast to float16: 0.0000000298023223876953125
    • the smallest double which does not round to 0 when cast to float16, i.e. the next double after the one in the previous bullet point: 0.00000002980232238769531911744490042422139897126953655970282852649688720703125
    • the smallest double which rounds to Infinity when cast to float16: $b^{emax} \times \lparen b - \frac{1}{2} b ^ {1 - p} \rparen$ i.e. $2^{15} \times \lparen 2 - \frac{1}{2} 2 ^ {1 - 11} \rparen =$ 65520
    • the largest double which does not round to Infinity when cast to float16 (i.e. the next double below 65520): 65519.9999999999927240423858165740966796875
    • the smallest double which rounds to a non-subnormal float16: 0.0000610053539276123046875
    • the largest double which rounds to a subnormal float16, i.e. the next double below the one in the previous bullet point: 0.0000610053539276122979112364219655972874534199945628643035888671875
    • some values which are precisely halfway between two adjacent float16 values, to test roundTiesToEven, including
      • a subnormal which rounds up
      • a subnormal which rounds down
      • a number with magnitude between 1 and 2047 which rounds up
      • a number with magnitude between 1 and 2047 which rounds down
      • a number with magnitude above 2047 which rounds up
      • a number with magnitude above 2047 which rounds down
    • all of those again but negative

Incidentally float.exposed is a great tool for exploring the representation of these values, though it has some edge-case bugs when converting between representations (edit: no longer true; I reported the issue and the owner fixed it).

@bakkot
Copy link
Contributor Author

bakkot commented Jun 11, 2023

I've started working on this.

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

Successfully merging a pull request may close this issue.

1 participant