Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Timeline for Stay away from zero

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
Jun 17, 2020 at 9:04 history edited Community Bot
Commonmark migration
Dec 17, 2017 at 23:26 comment added Arnauld @StanStrum We're required to return the original value of n if it's not zero. A bitwise OR would modify n whenever the least significant bit is not set (e.g. (4|1) === 5).
Dec 17, 2017 at 23:21 comment added Stan Strum Why not n|1...? It makes sure the 1s place is always 1, making it not possible for it to be 0
May 4, 2017 at 1:40 comment added Arnauld @ansiart If your point is that n=>n||1 could be simplified to n||1, then no. Acceptable answers are either full programs or functions. n=>do_something_with(n) is an arrow function in ES6 syntax.
May 3, 2017 at 22:42 comment added ansiart this can be simplified to n||1. Only thing that evaluates to false is 0.
May 2, 2017 at 16:48 comment added Arnauld @SIGSEGV Yes, that would work indeed. (That could also be n|!n, although this one is limited to a 31-bit quantity.)
May 2, 2017 at 16:45 comment added Matthew Roh Alternative: n=>n+!n (At least I think)
May 2, 2017 at 16:42 history answered Arnauld CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /