[issue45917] Add math.exp2() function: 2^x

2021-11-30 Thread Mark Dickinson
Mark Dickinson added the comment: [Tim] > on Windows, exp2(x) is way worse then pow(2, x) Darn. > I expect we should just live with it. Agreed. -- ___ Python tracker ___ _

[issue45917] Add math.exp2() function: 2^x

2021-11-29 Thread Tim Peters
Tim Peters added the comment: Across millions of tries, same thing: Windows exp2 is off by at least 1 ulp over a third of the time, and by over 2 ulp about 3 times per million. Still haven't seen pow(2, x) off by as much as 0.52 ulp. >From its behavior, it appears Windows implements exp2(x)

[issue45917] Add math.exp2() function: 2^x

2021-11-29 Thread Tim Peters
Tim Peters added the comment: Bad news: on Windows, exp2(x) is way worse then pow(2, x). Here I changed the loop of Mark's little driver like so: differ = really_bad = 0 worst = 0.0 for n in range(100_000): x = random.uniform(-1000.0, 999.0) + random.random() if ex

[issue45917] Add math.exp2() function: 2^x

2021-11-29 Thread Mark Dickinson
Mark Dickinson added the comment: All done. Many thanks, Gideon! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___

[issue45917] Add math.exp2() function: 2^x

2021-11-29 Thread Mark Dickinson
Mark Dickinson added the comment: New changeset 6266e4af873a27c9d352115f2f7a1ad0885fc031 by Gideon in branch 'main': bpo-45917: Add math.exp2() method - return 2 raised to the power of x (GH-29829) https://github.com/python/cpython/commit/6266e4af873a27c9d352115f2f7a1ad0885fc031 --

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Gideon
Gideon added the comment: I've submitted a PR at https://github.com/python/cpython/pull/29829. I'd just like to add that the whole Python team is amazing. Thank you for doing what you do! -- ___ Python tracker

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Roundup Robot
Change by Roundup Robot : -- keywords: +patch nosy: +python-dev nosy_count: 5.0 -> 6.0 pull_requests: +28060 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29829 ___ Python tracker _

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Gideon
Gideon added the comment: Sounds good. I've already made the necessary code changes on my own build, so I'll just finish writing the tests + documentation and submit a PR. -- ___ Python tracker

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Mark Dickinson
Mark Dickinson added the comment: On the subject of accuracy, there doesn't seem to be much in it on my mac laptop, and it looks as though pow(2.0, x) is giving correctly rounded results as often as (if not more often than) exp2(x). Here's the log of a terminal session, after recompiling Pyt

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Mark Dickinson
Mark Dickinson added the comment: See also previous discussion towards the end of https://bugs.python.org/issue3366. FWIW, I don't think there's value in adding exp2 to the cmath module too: we'd have to write our own implementation, and it's just not a function that appears often in the co

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Mark Dickinson
Mark Dickinson added the comment: Sounds good to me, provided that all the common platforms that we care about have a reasonable quality implementation. This should be a straightforward wrapping of the C99 function, and with sufficient tests the buildbots should tell us if there are any issue

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +mark.dickinson, rhettinger, serhiy.storchaka, tim.peters ___ Python tracker ___ ___ Python-b

[issue45917] Add math.exp2() function: 2^x

2021-11-28 Thread Gideon
New submission from Gideon : Dear Python Support Team, I was looking through Python’s list of supported methods in the math module, and I noticed that C99’s exp2 method was not implemented. This method raises 2 to the power of the supplied argument. I understand that it’s pretty trivial to so