techhub.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A hub primarily for passionate technologists, but everyone is welcome

Administered by:

Server stats:

4.9K
active users

#log2

0 posts0 participants0 posts today
Sergey Shandar<p><a href="https://techhub.social/tags/JavaScript" class="mention hashtag" rel="tag">#<span>JavaScript</span></a> is a weird language; it has <a href="https://techhub.social/tags/bigint" class="mention hashtag" rel="tag">#<span>bigint</span></a>, but it doesn&#39;t have a function that returns a number of bits in the bigint. Neither it has <a href="https://techhub.social/tags/log2" class="mention hashtag" rel="tag">#<span>log2</span></a> function for the bigints. If you need a workaround for the problem, see the article <a href="https://medium.com/@sergeyshandar/improving-the-log2-algorithm-for-bigint-in-javascript-7e5692e7bf0b?sk=9ac18367f61b524704cc8d82707aed3d" target="_blank" rel="nofollow noopener noreferrer" translate="no"><span class="invisible">https://</span><span class="ellipsis">medium.com/@sergeyshandar/impr</span><span class="invisible">oving-the-log2-algorithm-for-bigint-in-javascript-7e5692e7bf0b?sk=9ac18367f61b524704cc8d82707aed3d</span></a></p>
Sergey Shandar<p>Does anyone know how to make a fast log2 function for bigint in JavaScript? </p><p>I know that JS VM can do it in almost O(1) because it has information about the size of bigint. My current best algorithm is O(log(n)). The algorithm performs faster than x.toString(2).length and consumes less memory. Do you have any ideas for improvement?</p><p><a href="https://github.com/functionalscript/functionalscript/blob/a9a1cd2c1b0f4c025faf2223eb6ff96f48e8374b/types/bigint/module.f.cjs#L65" target="_blank" rel="nofollow noopener noreferrer" translate="no"><span class="invisible">https://</span><span class="ellipsis">github.com/functionalscript/fu</span><span class="invisible">nctionalscript/blob/a9a1cd2c1b0f4c025faf2223eb6ff96f48e8374b/types/bigint/module.f.cjs#L65</span></a></p><p><a href="https://techhub.social/tags/JavaScript" class="mention hashtag" rel="tag">#<span>JavaScript</span></a> <a href="https://techhub.social/tags/bigint" class="mention hashtag" rel="tag">#<span>bigint</span></a> <a href="https://techhub.social/tags/log2" class="mention hashtag" rel="tag">#<span>log2</span></a> <a href="https://techhub.social/tags/Algorithm" class="mention hashtag" rel="tag">#<span>Algorithm</span></a></p>