Post Reply 
[VA] SRC#002- Almost integers and other beasties
02-15-2019, 06:50 PM
Post: #32
RE: [VA] SRC#002- Almost integers and other beasties
(02-15-2019 04:29 PM)Gerson W. Barbosa Wrote:  a := 2^k - 1;
...
a := a div 2

Despite RPL does not see speedup, this is a great optimization !
Can the sign flipping code be removed, and possibly gain some speed ?

Code:
>>> sum, k = 0, 35       # for 12 digits accuracy
>>> a = (1<<k) - 1       # k bits of 1
>>> while k > 0:
...     sum = 1/(a*k) - sum
...     a, k = a>>1, k-1
...
>>> print sum
0.868876652659
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC#002- Almost integers and other beasties - Albert Chan - 02-15-2019 06:50 PM



User(s) browsing this thread: 2 Guest(s)