15:13 | <jmdyck> | Has the TC39 meeting next week been cancelled, or is it going to be all-remote? |
17:14 | <TabAtkins> | It's all remote, on zoom |
17:15 | <TabAtkins> | Hmm, I'm looking at ToInteger <https://tc39.es/ecma262/#sec-tointeger>, and step 4 says to convert it to a value with the same sign, but magnitude equal to floor(abs(value)). |
17:15 | <TabAtkins> | That's just trunctation, right? Why not refer to that? Is trunc() just not defined over abstract numbers? |
17:16 | <devsnek> | TabAtkins: yeah we haven't defined it |
17:16 | <TabAtkins> | Ok. |
17:17 | <devsnek> | https://tc39.es/ecma262/#sec-mathematical-operations |
17:19 | <TabAtkins> | Yeah, I just tried to reproduce the algo in code and thought it was weird. Turns out you can reduce the whole thing to a one-liner if you're working in JS rather than spec-ese: `Math.trunc(n) || 0;` |
17:19 | <TabAtkins> | That preserves Infinities, rounds toward 0, and converts NaN and -0 to +0, which is the entire algo. |