Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
penless304y>> is on integer values
!isfinite are converted to 0 per the standard
I don’t see the problem 👀 -
@penless No issue. I just didn’t realize that it coerced values to INT32 before bitwise operations
-
@AmyShackles I mean it's pretty hard to define shifts on floats.
What it could do is to convert it to INT_MIN, as they have an identical purpose. -
I don't get why people think this is undefined behavior. MDN docs literally explain this specific case.
-
@hashedram It isn't undefined behavior, it's stupid behavior. The smallest float possible should convert to the smallest integer possible, because both are primarily used as initial value for algorithms.
-
@homo-lorens something something I'm not used to dynamic typing so I'll moan about it
-
@hashedram My axioms:
Javascript doesn't let you explicitly specify types
-infinity has the same role as INT_MIN
My reasoning:
Because they have the same role, casting -infinity to INT_MIN would be the least disruptive.
Because javascript doesn't let you explicitly specify types, it doesn't expect you to keep track of the distinction between ints and floats
Because you aren't expected to know when a cast happens, it's best if the casts are the least disruptive possible.
Today I learned that -Infinity >> 0 = 0
rant
ecmascript
javascript
bitwise
bit is it wise tho?