-
Notifications
You must be signed in to change notification settings - Fork 22.4k
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
Reference for stage-3 float16array #33652
Conversation
Yes, because of some specific issues I delayed adding |
files/en-us/web/javascript/reference/global_objects/dataview/getfloat16/index.md
Show resolved
Hide resolved
|
||
The **`getFloat16()`** method of {{jsxref("DataView")}} instances reads 2 bytes starting at the specified byte offset of this `DataView` and interprets them as a 16-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. | ||
|
||
{{EmbedInteractiveExample("pages/js/dataview-getfloat16.html")}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't rendering - I presume is "in progress"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR number please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
files/en-us/web/javascript/reference/global_objects/dataview/getfloat16/index.md
Show resolved
Hide resolved
const buffer = new ArrayBuffer(10); | ||
const dataview = new DataView(buffer); | ||
dataview.setFloat16(0, 3); | ||
dataview.getFloat16(1); // 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more useful to show setting and getting the same buffer index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that somewhat feels trivial to me though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the question is, what does someone learn from having the getter in an example in the setter?
From this they could learn "by default the buffer is zero filled", which is interesting but requires a little thinking. It feels odd and pointless.
In the getFloat16()
example you arbitrarily-sh populate the array and then get the float. This returns a value 0.00001537799835205078
which is kind of cool because it shows that the input values aren't trivially encoded into a real number. But it is also frustrating, because you can't look at the inputs and say "hey, that's the right output".
So when I saw this, I thought - ah, cool, I can see that the value in and out do match. It would be even better if I could see the values in the buffer as bytes too, but.
Anyway, those are my reasons why I would either delete the getter or make it get a value that you set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not fetching the default zero-filled value here. We are setting the 0th byte and 1st byte and then reading the 1st and 2nd byte. It just happens that we read out the value 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice that, so what does that tell you about the example?
Obviously you don't want to change this, and its a small speck in otherwise excellent docs so I'll merge.
files/en-us/web/javascript/reference/global_objects/math/f16round/index.md
Outdated
Show resolved
Hide resolved
Looks great. Just a few editorial type questions. |
files/en-us/web/javascript/reference/global_objects/math/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/math/f16round/index.md
Outdated
Show resolved
Hide resolved
@@ -43,51 +43,53 @@ Unlike most global objects, `Math` is not a constructor. You cannot use it with | |||
## Static methods | |||
|
|||
- {{jsxref("Math.abs()")}} | |||
- : Returns the absolute value of `x`. | |||
- : Returns the absolute value of the input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @Josh-Cena I replaced x
by "the input" (or similar) for all the other cases in the math parent page. Left a few log/exponential cases where the use of x
, y
is more useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, but see comments - such as PR for the interactive examples.
Thanks very much for sorting this out. |
Part of #33561.
cc @hamishwillee maybe you want to review this.
cc @zloirock I cannot find a polyfill link for
Float16Array
itself and I assume that's intentional.For whoever is reviewing this: please watch out for any copy/paste remnants since they are mostly copy/pasted...