Topic: Optimizing Power Function for Integral Types
Author: joel.g.hemphill@gmail.com
Date: Thu, 17 Jan 2019 08:02:13 -0800 (PST)
Raw View
------=_Part_159_387068105.1547740933607
Content-Type: multipart/alternative;
boundary="----=_Part_160_1686897718.1547740933607"
------=_Part_160_1686897718.1547740933607
Content-Type: text/plain; charset="UTF-8"
As of C++11, per overload 7 of the 'pow' function (
https://en.cppreference.com/w/cpp/numeric/math/pow), integral types can be
used as parameters, but they will be cast to double before calculation. I
believe that an integral-specific overload should be made, which makes use
of faster integer-operations available to CPUs.
As a disclaimer, I am still a rather inexperienced programmer (College
Sophomore), and I my have some misunderstands as to what would fall under
the ISO standard and what would fall under compiler-implementations. As I
understand it, the line about "If any argument has integral type, it is
cast to double." is a component of the ISO standard.
As stated on isocpp.org's FAQ section, this idea is based on existing
practices. As discussed here (
https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-exponent-in-the-standard-c-libraries),
multiple implementations of this function have been made on a per-user
basis, due to its general simplicity and lack of inclusion in previous
standards. In the below testing, I created a function using x86 asm. It is
worth noting that even with more standard C++ approaches, as testified in
the stackoverflow discussion above, a significant performance improvement
can be made.
For the sake of brevity, the data-table and source have been withheld, but
if it is relevant to the conversation, I would be more than willing to
provide them.
Do any of you agree that this is a useful addition to the C++ standards?
*Performance Testing:*
Tests were run on an Intel Core i3 6006U @ 2.0GHz
Custom Function (VS 2017) :
__declspec(naked) __int32 __fastcall powi(__int32 base, __int32 exp) {
__asm { ... } }
Test Range:
base: [-46340, 46340] (int-truncation of the sqrt of MAX_INT)
exp: [-19, 19] (highest power of 3, that does not overflow the int type)
Results: (Approx. x20 avg. improvement)
[image: Untitled.png]
*Possible Use-Cases:*
Allocation of N-dimensional arrays, with N^M elements.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fbfec82c-5416-4c96-b53b-ef3d4309b613%40isocpp.org.
------=_Part_160_1686897718.1547740933607
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">As of C++11, per overload 7 of the 'pow' function =
(<a href=3D"https://en.cppreference.com/w/cpp/numeric/math/pow">https://en.=
cppreference.com/w/cpp/numeric/math/pow</a>), integral types can be used as=
parameters, but they will be cast to double before calculation. I believe =
that an integral-specific overload should be made, which makes use of faste=
r integer-operations available to CPUs.<div><br></div><div>As a disclaimer,=
I am still a rather inexperienced programmer (College Sophomore), and I my=
have some misunderstands as to what would fall under the ISO standard and =
what would fall under compiler-implementations. As I understand it, the lin=
e about "<span style=3D"color: rgb(0, 0, 0); font-family: DejaVuSans, =
"DejaVu Sans", arial, sans-serif; font-size: 12.8px; text-indent:=
-64px;">If any argument has integral type,=C2=A0</span><span style=3D"colo=
r: rgb(0, 0, 0); font-family: DejaVuSans, "DejaVu Sans", arial, s=
ans-serif; font-size: 12.8px; text-indent: -64px;">it is cast to double.&qu=
ot; is a component of the ISO standard.</span></div><div><span style=3D"col=
or: rgb(0, 0, 0); font-family: DejaVuSans, "DejaVu Sans", arial, =
sans-serif; font-size: 12.8px; text-indent: -64px;"><br></span></div><div s=
tyle=3D"text-indent: 0px;"><span style=3D"color: rgb(0, 0, 0); font-family:=
DejaVuSans, "DejaVu Sans", arial, sans-serif; font-size: 12.8px;=
text-indent: -64px;">As stated on isocpp.org's FAQ section, this idea =
is based on existing practices. As discussed here (</span><font color=3D"#0=
00000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><a href=3D"https=
://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-exponen=
t-in-the-standard-c-libraries" style=3D"font-size: 12.8px;">https://stackov=
erflow.com/questions/2398442/why-isnt-int-powint-base-int-exponent-in-the-s=
tandard-c-libraries</a><span style=3D"font-size: 12.8px;">), multiple imple=
mentations=C2=A0of this function have been made on a per-user basis, due to=
its general simplicity and lack of inclusion in previous standards. In the=
below testing, I created a function using x86 asm. It is worth noting that=
even with more standard C++ approaches, as testified in the stackoverflow =
discussion above, a significant performance improvement can be made.</span>=
</font></div><div style=3D"text-indent: 0px;"><font color=3D"#000000" face=
=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"font-size: 1=
2.8px;"><br></span></font></div><div style=3D"text-indent: 0px;"><font colo=
r=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><span sty=
le=3D"font-size: 12.8px;">For the sake of brevity, the data-table and sourc=
e have been withheld, but if it is relevant=C2=A0to the conversation, I wou=
ld be more than willing to provide them.</span></font></div><div style=3D"t=
ext-indent: 0px;"><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, =
arial, sans-serif"><span style=3D"font-size: 12.8px;"><br></span></font></d=
iv><div style=3D"text-indent: 0px;"><font color=3D"#000000" face=3D"DejaVuS=
ans, DejaVu Sans, arial, sans-serif"><span style=3D"font-size: 12.8px;">Do =
any of you agree that this is a useful addition to the C++ standards?</span=
></font></div><div><b><br></b></div><div><b>Performance Testing:</b></div><=
div><div><font size=3D"1">Tests were run on an Intel Core i3 6006U @ 2.0GHz=
</font></div><div><br></div><div>Custom Function (VS 2017) : <div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: r=
gb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
style=3D"color: #000;" class=3D"styled-by-prettify">__declspec</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">naked</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> __int32 __fastcall powi</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">__int32 </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">base</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> __int32 exp</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> __asm =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">}</span></div></code></div></div><div><br></div><div>Test Ra=
nge:</div><blockquote style=3D"margin: 0 0 0 40px; border: none; padding: 0=
px;"><div>base: [-46340, 46340]=C2=A0 (int-truncation of the sqrt of MAX_IN=
T)</div></blockquote><blockquote style=3D"margin: 0 0 0 40px; border: none;=
padding: 0px;">exp: [-19, 19] (highest power of 3, that does not overflow =
the int type)</blockquote><div><br></div><div>Results: (Approx. x20 avg. im=
provement)</div><p class=3D"separator" style=3D"text-align: left; clear: bo=
th;"><img src=3D"cid:8babe2aa-8688-46ef-8cca-eca48b935eda" alt=3D"Untitled.=
png" width=3D"320" height=3D"183" style=3D"margin-left: 1em; margin-right: =
1em;"></p><p class=3D"separator" style=3D"text-align: left; clear: both;"><=
br></p><p class=3D"separator" style=3D"text-align: left; clear: both;"><b>P=
ossible Use-Cases:</b></p><p class=3D"separator" style=3D"text-align: left;=
clear: both;">Allocation of N-dimensional arrays, with N^M elements.</p></=
div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/fbfec82c-5416-4c96-b53b-ef3d4309b613%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fbfec82c-5416-4c96-b53b-ef3d4309b613=
%40isocpp.org</a>.<br />
------=_Part_160_1686897718.1547740933607--
------=_Part_159_387068105.1547740933607
Content-Type: image/png; name=Untitled.png
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=Untitled.png
X-Attachment-Id: 8babe2aa-8688-46ef-8cca-eca48b935eda
Content-ID: <8babe2aa-8688-46ef-8cca-eca48b935eda>
iVBORw0KGgoAAAANSUhEUgAAAfQAAAEfCAIAAAA4N6OcAAAmHElEQVR42u2d728cVZrv+VPmX9hX
vLni1WilO0ir4Q3Cuiia0YiLRmiQbiKPgtBgcQdLGUF2TF5YbATW8mOIBD0sYXYiAiiaiUjG60DI
JBCTxDcb6ARINrETJ3HseJ3cr/uxj0/Xz1On2+3+8fmolbS7u6pOnar6nKeeOlXngQsXLpwBAIA+
QmJ/QP/dBwCAPkJiR+4AAMgdAACQOwAAIHcAAEDuAACA3AEAkDsAACB3AABA7gAAgNwBAAC5AwAg
d+QOAIDcAQAAuQMAAHIHiKVeGx4aGq7VqQkA5N5j0pkcG2qmu1SWKt7Q0Nhkf8m9sYxE7WesdtPq
r37f2Q3VVEraO+QOXSKdAhckvjKrdNKfAXLvXHE6Ls3EhtSfycVn1kBny2li98qw+kFLi+984wTI
fdDl3nGdDrbcA1Zvy+Xe2NfavAmQO3KHQLmvh1Ibp/PrXzafTqc9kTrMsmadMXWqeUlKKOkEP9OQ
/tn6UoLi1uxvmtYkv0LyypNZUam1zKmNoCXmrUTx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e5QwOyD3dsndudze
W+BOBgc6xO0PRjE7IPcOyN39ujwtU6/XzwC0zMU/PCuzf//aU2dOf0ltQOtITcg9T+5ZfwMAELl3
E94l0mQ0npR7rRGxcz0VAOA+NzEBACB3AABA7gAAgNwBAAC5AwAAcgcAQO4AAIDcAQAAuQMAAHIH
AADkDgAAyB0AALkDAAByBwAA5A4AAMgdAACQOwAAcgcAAOQO0HbcEIuNAXTr/iiKjU+Hh7tlNMXm
kgIgd4AiYa6rcnJsQ+LeYOldMgr6aquzVg69DSpR9ojvAMgdBkvuOV7sDrlnlDM5dPtkc3ifHMbd
OydZn2xybLhWG1v/bP0HNAiA3KFDTE3PPv7CZz/e/mlbXprVwanLiWRHwmhxcr979sjc7oev/eYf
2vXS3BaP788JwrPk3lRYfyK/cXDvV1fdft6ohMZb7wwBALnD5tJGs9vrJ78+mo6MfcPHyb29ZrfX
7PMPVpB7U1OVuxIbTcH6992XhgLkDgPAvk/q7ZX7WG3mflEqJlJ2C4cn2i732x+M5pQiOy1zfyMF
MzyM3AG5w2DiX5v0rdZ9sttIoaxf+t0oY8PlGe4fGspKy2wkXpA7IHfoW7wLkJ7TmmWX9YstaYgS
XSFd0cZq1kg1deR0l0j9hM1Qs/GROyB3AABA7gAAyB0AAJA7AAAgdwAAQO4AAIDcAQCQO3IHAEDu
AACA3AEAALkDAAByBwAA5A4AgNwBAAC5AwAAcgcAgE2U+7lz584AAEAfIbH/f2QRsfACmWPMAAAA
AElFTkSuQmCC
------=_Part_159_387068105.1547740933607--
.
Author: Dilip Ranganathan <misc.usage@gmail.com>
Date: Thu, 17 Jan 2019 11:06:11 -0500
Raw View
--0000000000005b32d3057fa99317
Content-Type: multipart/alternative; boundary="0000000000005b32d0057fa99316"
--0000000000005b32d0057fa99316
Content-Type: text/plain; charset="UTF-8"
I am just writing to +1 this. I have long wondered why there is no int
overload
for the pow function but wasn't confident enough of asking here fearing that
I would've missed something blindingly obvious.
Thanks Joel for taking that baton.
On Thu, Jan 17, 2019 at 11:02 AM <joel.g.hemphill@gmail.com> wrote:
> As of C++11, per overload 7 of the 'pow' function (
> https://en.cppreference.com/w/cpp/numeric/math/pow), integral types can
> be used as parameters, but they will be cast to double before calculation.
> I believe that an integral-specific overload should be made, which makes
> use of faster integer-operations available to CPUs.
>
> As a disclaimer, I am still a rather inexperienced programmer (College
> Sophomore), and I my have some misunderstands as to what would fall under
> the ISO standard and what would fall under compiler-implementations. As I
> understand it, the line about "If any argument has integral type, it is
> cast to double." is a component of the ISO standard.
>
> As stated on isocpp.org's FAQ section, this idea is based on existing
> practices. As discussed here (
> https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-exponent-in-the-standard-c-libraries),
> multiple implementations of this function have been made on a per-user
> basis, due to its general simplicity and lack of inclusion in previous
> standards. In the below testing, I created a function using x86 asm. It is
> worth noting that even with more standard C++ approaches, as testified in
> the stackoverflow discussion above, a significant performance improvement
> can be made.
>
> For the sake of brevity, the data-table and source have been withheld, but
> if it is relevant to the conversation, I would be more than willing to
> provide them.
>
> Do any of you agree that this is a useful addition to the C++ standards?
>
> *Performance Testing:*
> Tests were run on an Intel Core i3 6006U @ 2.0GHz
>
> Custom Function (VS 2017) :
> __declspec(naked) __int32 __fastcall powi(__int32 base, __int32 exp) {
> __asm { ... } }
>
> Test Range:
>
> base: [-46340, 46340] (int-truncation of the sqrt of MAX_INT)
>
> exp: [-19, 19] (highest power of 3, that does not overflow the int type)
>
>
> Results: (Approx. x20 avg. improvement)
>
> [image: Untitled.png]
>
>
> *Possible Use-Cases:*
>
> Allocation of N-dimensional arrays, with N^M elements.
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fbfec82c-5416-4c96-b53b-ef3d4309b613%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fbfec82c-5416-4c96-b53b-ef3d4309b613%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALEPxfvZRppNMssi7byXc0oNuuw_Q88YhW7huMN0q4SJnXK-mw%40mail.gmail.com.
--0000000000005b32d0057fa99316
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I am just writing to=C2=A0+1 this. I have long wondered wh=
y there is no int overload<br>for the pow function but wasn't confident=
enough of asking here fearing that<br>I would've missed something blin=
dingly obvious.<div><br></div><div>Thanks Joel for taking that baton.</div>=
</div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Thu, Jan 17, 2019 =
at 11:02 AM <<a href=3D"mailto:joel.g.hemphill@gmail.com">joel.g.hemphil=
l@gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div dir=3D"ltr">As of C++11, per overload 7 of the 'pow'=
; function (<a href=3D"https://en.cppreference.com/w/cpp/numeric/math/pow" =
target=3D"_blank">https://en.cppreference.com/w/cpp/numeric/math/pow</a>), =
integral types can be used as parameters, but they will be cast to double b=
efore calculation. I believe that an integral-specific overload should be m=
ade, which makes use of faster integer-operations available to CPUs.<div><b=
r></div><div>As a disclaimer, I am still a rather inexperienced programmer =
(College Sophomore), and I my have some misunderstands as to what would fal=
l under the ISO standard and what would fall under compiler-implementations=
.. As I understand it, the line about "<span style=3D"color:rgb(0,0,0);=
font-family:DejaVuSans,"DejaVu Sans",arial,sans-serif;font-size:1=
2.8px">If any argument has integral type,=C2=A0</span><span style=3D"color:=
rgb(0,0,0);font-family:DejaVuSans,"DejaVu Sans",arial,sans-serif;=
font-size:12.8px">it is cast to double." is a component of the ISO sta=
ndard.</span></div><div><span style=3D"color:rgb(0,0,0);font-family:DejaVuS=
ans,"DejaVu Sans",arial,sans-serif;font-size:12.8px"><br></span><=
/div><div style=3D"text-indent:0px"><span style=3D"color:rgb(0,0,0);font-fa=
mily:DejaVuSans,"DejaVu Sans",arial,sans-serif;font-size:12.8px">=
As stated on <a href=3D"http://isocpp.org" target=3D"_blank">isocpp.org</a>=
's FAQ section, this idea is based on existing practices. As discussed =
here (</span><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial=
, sans-serif"><a href=3D"https://stackoverflow.com/questions/2398442/why-is=
nt-int-powint-base-int-exponent-in-the-standard-c-libraries" style=3D"font-=
size:12.8px" target=3D"_blank">https://stackoverflow.com/questions/2398442/=
why-isnt-int-powint-base-int-exponent-in-the-standard-c-libraries</a><span =
style=3D"font-size:12.8px">), multiple implementations=C2=A0of this functio=
n have been made on a per-user basis, due to its general simplicity and lac=
k of inclusion in previous standards. In the below testing, I created a fun=
ction using x86 asm. It is worth noting that even with more standard C++ ap=
proaches, as testified in the stackoverflow discussion above, a significant=
performance improvement can be made.</span></font></div><div style=3D"text=
-indent:0px"><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial=
, sans-serif"><span style=3D"font-size:12.8px"><br></span></font></div><div=
style=3D"text-indent:0px"><font color=3D"#000000" face=3D"DejaVuSans, Deja=
Vu Sans, arial, sans-serif"><span style=3D"font-size:12.8px">For the sake o=
f brevity, the data-table and source have been withheld, but if it is relev=
ant=C2=A0to the conversation, I would be more than willing to provide them.=
</span></font></div><div style=3D"text-indent:0px"><font color=3D"#000000" =
face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"font-siz=
e:12.8px"><br></span></font></div><div style=3D"text-indent:0px"><font colo=
r=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><span sty=
le=3D"font-size:12.8px">Do any of you agree that this is a useful addition =
to the C++ standards?</span></font></div><div><b><br></b></div><div><b>Perf=
ormance Testing:</b></div><div><div><font size=3D"1">Tests were run on an I=
ntel Core i3 6006U @ 2.0GHz</font></div><div><br></div><div>Custom Function=
(VS 2017) : <div class=3D"gmail-m_4824888265353890807prettyprint" style=3D=
"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-sty=
le:solid;border-width:1px"><code class=3D"gmail-m_4824888265353890807pretty=
print"><div class=3D"gmail-m_4824888265353890807subprettyprint"><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_4824888265353890807styled-by-prettif=
y">__declspec</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_4=
824888265353890807styled-by-prettify">(</span><span style=3D"color:rgb(0,0,=
0)" class=3D"gmail-m_4824888265353890807styled-by-prettify">naked</span><sp=
an style=3D"color:rgb(102,102,0)" class=3D"gmail-m_4824888265353890807style=
d-by-prettify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_48=
24888265353890807styled-by-prettify"> __int32 __fastcall powi</span><span s=
tyle=3D"color:rgb(102,102,0)" class=3D"gmail-m_4824888265353890807styled-by=
-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_482488=
8265353890807styled-by-prettify">__int32 </span><span style=3D"color:rgb(0,=
0,136)" class=3D"gmail-m_4824888265353890807styled-by-prettify">base</span>=
<span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_4824888265353890807st=
yled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_4824888265353890807styled-by-prettify"> __int32 exp</span><span style=3D"c=
olor:rgb(102,102,0)" class=3D"gmail-m_4824888265353890807styled-by-prettify=
">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_482488826535389=
0807styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_4824888265353890807styled-by-prettify">{</span><span style=3D"c=
olor:rgb(0,0,0)" class=3D"gmail-m_4824888265353890807styled-by-prettify"> _=
_asm </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_482488826=
5353890807styled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" clas=
s=3D"gmail-m_4824888265353890807styled-by-prettify"> </span><span style=3D"=
color:rgb(102,102,0)" class=3D"gmail-m_4824888265353890807styled-by-prettif=
y">...</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_482488826535=
3890807styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" cla=
ss=3D"gmail-m_4824888265353890807styled-by-prettify">}</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_4824888265353890807styled-by-prettify">=
</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_4824888265353=
890807styled-by-prettify">}</span></div></code></div></div><div><br></div><=
div>Test Range:</div><blockquote style=3D"margin:0px 0px 0px 40px;border:no=
ne;padding:0px"><div>base: [-46340, 46340]=C2=A0 (int-truncation of the sqr=
t of MAX_INT)</div></blockquote><blockquote style=3D"margin:0px 0px 0px 40p=
x;border:none;padding:0px">exp: [-19, 19] (highest power of 3, that does no=
t overflow the int type)</blockquote><div><br></div><div>Results: (Approx. =
x20 avg. improvement)</div><p class=3D"gmail-m_4824888265353890807separator=
" style=3D"text-align:left;clear:both"><img src=3D"cid:8babe2aa-8688-46ef-8=
cca-eca48b935eda" alt=3D"Untitled.png" width=3D"320" height=3D"183" style=
=3D"margin-left: 1em; margin-right: 1em;"></p><p class=3D"gmail-m_482488826=
5353890807separator" style=3D"text-align:left;clear:both"><br></p><p class=
=3D"gmail-m_4824888265353890807separator" style=3D"text-align:left;clear:bo=
th"><b>Possible Use-Cases:</b></p><p class=3D"gmail-m_4824888265353890807se=
parator" style=3D"text-align:left;clear:both">Allocation of N-dimensional a=
rrays, with N^M elements.</p></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/fbfec82c-5416-4c96-b53b-ef3d4309b613%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fbfec82c-5416-=
4c96-b53b-ef3d4309b613%40isocpp.org</a>.<br>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALEPxfvZRppNMssi7byXc0oNuuw_Q88YhW7h=
uMN0q4SJnXK-mw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALEPxfvZRppNMssi=
7byXc0oNuuw_Q88YhW7huMN0q4SJnXK-mw%40mail.gmail.com</a>.<br />
--0000000000005b32d0057fa99316--
--0000000000005b32d3057fa99317
Content-Type: image/png; name="Untitled.png"
Content-Disposition: inline; filename="Untitled.png"
Content-Transfer-Encoding: base64
Content-ID: <8babe2aa-8688-46ef-8cca-eca48b935eda>
X-Attachment-Id: 8babe2aa-8688-46ef-8cca-eca48b935eda
iVBORw0KGgoAAAANSUhEUgAAAfQAAAEfCAIAAAA4N6OcAAAmHElEQVR42u2d728cVZrv+VPmX9hX
vLni1WilO0ir4Q3C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f+t0oY8PlGe4fGspKy2wkXpA7IHfoW7wLkJ7TmmWX9YstaYgS
XSFd0cZq1kg1deR0l0j9hM1Qs/GROyB3AABA7gAAyB0AAJA7AAAgdwAAQO4AAIDcAQCQO3IHAEDu
AACA3AEAALkDAAByBwAA5A4AgNwBAAC5AwAAcgcAgE2U+7lz584AAEAfIbH/f2QRsfACmWPMAAAA
AElFTkSuQmCC
--0000000000005b32d3057fa99317--
.
Author: joel.g.hemphill@gmail.com
Date: Fri, 18 Jan 2019 10:12:53 -0800 (PST)
Raw View
------=_Part_1072_176754651.1547835173821
Content-Type: multipart/alternative;
boundary="----=_Part_1073_35091478.1547835173822"
------=_Part_1073_35091478.1547835173822
Content-Type: text/plain; charset="UTF-8"
To amend the graph given; I have discovered a mistake in my timing code.
After fixing said mistake, the graph no-longer shows O(log(n)) complexity
for either function with positive powers. The 20x improvement in
performance is still present. I know that this doesn't effect the primary
points of the proposal, but I just wanted to clarify a bit of information.
On Thursday, January 17, 2019 at 8:02:13 AM UTC-8, joel.g....@gmail.com
wrote:
>
> As of C++11, per overload 7 of the 'pow' function (
> https://en.cppreference.com/w/cpp/numeric/math/pow), integral types can
> be used as parameters, but they will be cast to double before calculation.
> I believe that an integral-specific overload should be made, which makes
> use of faster integer-operations available to CPUs.
>
> As a disclaimer, I am still a rather inexperienced programmer (College
> Sophomore), and I my have some misunderstands as to what would fall under
> the ISO standard and what would fall under compiler-implementations. As I
> understand it, the line about "If any argument has integral type, it is
> cast to double." is a component of the ISO standard.
>
> As stated on isocpp.org's FAQ section, this idea is based on existing
> practices. As discussed here (
> https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-exponent-in-the-standard-c-libraries),
> multiple implementations of this function have been made on a per-user
> basis, due to its general simplicity and lack of inclusion in previous
> standards. In the below testing, I created a function using x86 asm. It is
> worth noting that even with more standard C++ approaches, as testified in
> the stackoverflow discussion above, a significant performance improvement
> can be made.
>
> For the sake of brevity, the data-table and source have been withheld, but
> if it is relevant to the conversation, I would be more than willing to
> provide them.
>
> Do any of you agree that this is a useful addition to the C++ standards?
>
> *Performance Testing:*
> Tests were run on an Intel Core i3 6006U @ 2.0GHz
>
> Custom Function (VS 2017) :
> __declspec(naked) __int32 __fastcall powi(__int32 base, __int32 exp) {
> __asm { ... } }
>
> Test Range:
>
> base: [-46340, 46340] (int-truncation of the sqrt of MAX_INT)
>
> exp: [-19, 19] (highest power of 3, that does not overflow the int type)
>
>
> Results: (Approx. x20 avg. improvement)
>
> [image: Untitled.png]
>
>
> *Possible Use-Cases:*
>
> Allocation of N-dimensional arrays, with N^M elements.
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f45294da-8e0b-4e2c-aa9d-e9b3f36371b5%40isocpp.org.
------=_Part_1073_35091478.1547835173822
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">To amend the graph given; I have discovered a mistake in m=
y timing code. After fixing said mistake, the graph no-longer shows O(log(n=
)) complexity for either function with positive powers. The 20x improvement=
in performance is still present. I know that this doesn't effect the p=
rimary points of the proposal, but I just wanted to clarify a bit of inform=
ation.<div><br>On Thursday, January 17, 2019 at 8:02:13 AM UTC-8, joel.g...=
..@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">As of C++11, per overload 7 of the 'pow' function (<a href=3D"=
https://en.cppreference.com/w/cpp/numeric/math/pow" target=3D"_blank" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.com/url?q\=
x3dhttps%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fnumeric%2Fmath%2Fpow\x26sa=
\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF58qoLigGYXuRNd7iC7b_Cp3V1aA';return=
true;" onclick=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%3=
A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fnumeric%2Fmath%2Fpow\x26sa\x3dD\x26s=
ntz\x3d1\x26usg\x3dAFQjCNF58qoLigGYXuRNd7iC7b_Cp3V1aA';return true;">ht=
tps://en.cppreference.com/<wbr>w/cpp/numeric/math/pow</a>), integral types =
can be used as parameters, but they will be cast to double before calculati=
on. I believe that an integral-specific overload should be made, which make=
s use of faster integer-operations available to CPUs.<div><br></div><div>As=
a disclaimer, I am still a rather inexperienced programmer (College Sophom=
ore), and I my have some misunderstands as to what would fall under the ISO=
standard and what would fall under compiler-implementations. As I understa=
nd it, the line about "<span style=3D"color:rgb(0,0,0);font-family:Dej=
aVuSans,"DejaVu Sans",arial,sans-serif;font-size:12.8px">If any a=
rgument has integral type,=C2=A0</span><span style=3D"color:rgb(0,0,0);font=
-family:DejaVuSans,"DejaVu Sans",arial,sans-serif;font-size:12.8p=
x">it is cast to double." is a component of the ISO standard.</span></=
div><div><span style=3D"color:rgb(0,0,0);font-family:DejaVuSans,"DejaV=
u Sans",arial,sans-serif;font-size:12.8px"><br></span></div><div style=
=3D"text-indent:0px"><span style=3D"color:rgb(0,0,0);font-family:DejaVuSans=
,"DejaVu Sans",arial,sans-serif;font-size:12.8px">As stated on <a=
href=3D"http://isocpp.org" target=3D"_blank" rel=3D"nofollow" onmousedown=
=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fisocpp.org=
\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHaIcX84r8AUHgx9Q4pR00LZ1llsQ';=
return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dht=
tp%3A%2F%2Fisocpp.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHaIcX84r8AUHg=
x9Q4pR00LZ1llsQ';return true;">isocpp.org</a>'s FAQ section, this i=
dea is based on existing practices. As discussed here (</span><font color=
=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><a href=3D=
"https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-e=
xponent-in-the-standard-c-libraries" style=3D"font-size:12.8px" target=3D"_=
blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.=
com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F2398442%2Fwhy-is=
nt-int-powint-base-int-exponent-in-the-standard-c-libraries\x26sa\x3dD\x26s=
ntz\x3d1\x26usg\x3dAFQjCNHWzh0WCiD6kSmtYt-R3r1LOBIlPw';return true;" on=
click=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fsta=
ckoverflow.com%2Fquestions%2F2398442%2Fwhy-isnt-int-powint-base-int-exponen=
t-in-the-standard-c-libraries\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHWzh0=
WCiD6kSmtYt-R3r1LOBIlPw';return true;">https://stackoverflow.com/<wbr>q=
uestions/2398442/why-isnt-<wbr>int-powint-base-int-exponent-<wbr>in-the-sta=
ndard-c-libraries</a><span style=3D"font-size:12.8px">), multiple implement=
ations=C2=A0of this function have been made on a per-user basis, due to its=
general simplicity and lack of inclusion in previous standards. In the bel=
ow testing, I created a function using x86 asm. It is worth noting that eve=
n with more standard C++ approaches, as testified in the stackoverflow disc=
ussion above, a significant performance improvement can be made.</span></fo=
nt></div><div style=3D"text-indent:0px"><font color=3D"#000000" face=3D"Dej=
aVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"font-size:12.8px"><=
br></span></font></div><div style=3D"text-indent:0px"><font color=3D"#00000=
0" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"font-=
size:12.8px">For the sake of brevity, the data-table and source have been w=
ithheld, but if it is relevant=C2=A0to the conversation, I would be more th=
an willing to provide them.</span></font></div><div style=3D"text-indent:0p=
x"><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-ser=
if"><span style=3D"font-size:12.8px"><br></span></font></div><div style=3D"=
text-indent:0px"><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, a=
rial, sans-serif"><span style=3D"font-size:12.8px">Do any of you agree that=
this is a useful addition to the C++ standards?</span></font></div><div><b=
><br></b></div><div><b>Performance Testing:</b></div><div><div><font size=
=3D"1">Tests were run on an Intel Core i3 6006U @ 2.0GHz</font></div><div><=
br></div><div>Custom Function (VS 2017) : <div style=3D"background-color:rg=
b(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-widt=
h:1px"><code><div><span style=3D"color:#000">__declspec</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">naked</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> __int32 __fastcall powi=
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">__int3=
2 </span><span style=3D"color:#008">base</span><span style=3D"color:#660">,=
</span><span style=3D"color:#000"> __int32 exp</span><span style=3D"color:#=
660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
{</span><span style=3D"color:#000"> __asm </span><span style=3D"color:#660"=
>{</span><span style=3D"color:#000"> </span><span style=3D"color:#660">...<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">}</span></di=
v></code></div></div><div><br></div><div>Test Range:</div><blockquote style=
=3D"margin:0 0 0 40px;border:none;padding:0px"><div>base: [-46340, 46340]=
=C2=A0 (int-truncation of the sqrt of MAX_INT)</div></blockquote><blockquot=
e style=3D"margin:0 0 0 40px;border:none;padding:0px">exp: [-19, 19] (highe=
st power of 3, that does not overflow the int type)</blockquote><div><br></=
div><div>Results: (Approx. x20 avg. improvement)</div><p style=3D"text-alig=
n:left;clear:both"><img src=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/attach/13eb89bedb9e8f/Untitled.png?part=3D0.1&view=3D1&a=
mp;authuser=3D2" alt=3D"Untitled.png" width=3D"320" height=3D"183" style=3D=
"margin-left:1em;margin-right:1em"></p><p style=3D"text-align:left;clear:bo=
th"><br></p><p style=3D"text-align:left;clear:both"><b>Possible Use-Cases:<=
/b></p><p style=3D"text-align:left;clear:both">Allocation of N-dimensional =
arrays, with N^M elements.</p></div></div></blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f45294da-8e0b-4e2c-aa9d-e9b3f36371b5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f45294da-8e0b-4e2c-aa9d-e9b3f36371b5=
%40isocpp.org</a>.<br />
------=_Part_1073_35091478.1547835173822--
------=_Part_1072_176754651.1547835173821--
.
Author: joel.g.hemphill@gmail.com
Date: Fri, 18 Jan 2019 10:17:27 -0800 (PST)
Raw View
------=_Part_1034_616440545.1547835447667
Content-Type: multipart/alternative;
boundary="----=_Part_1035_1172686801.1547835447667"
------=_Part_1035_1172686801.1547835447667
Content-Type: text/plain; charset="UTF-8"
Thanks for the positive feedback. I will admit, there was a certain amount
of doubt when I was first considering pushing for this. It felt like every
good suggestion had already been made and considered; To a certain extent,
I had considered the STL holy. That's not to say I don't understand some of
the rationale behind this optimization's inclusion. Bloat is a major design
constraint.
On Thursday, January 17, 2019 at 8:06:25 AM UTC-8, Dilip R wrote:
>
> I am just writing to +1 this. I have long wondered why there is no int
> overload
> for the pow function but wasn't confident enough of asking here fearing
> that
> I would've missed something blindingly obvious.
>
> Thanks Joel for taking that baton.
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d0809e24-10f9-4def-a95a-7756424caf02%40isocpp.org.
------=_Part_1035_1172686801.1547835447667
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Thanks for the positive feedback. I will admit, there was =
a certain amount of doubt when I was first considering pushing for this. It=
felt like every good suggestion had already been made and considered; To a=
certain extent, I had considered the STL holy. That's not to say I don=
't understand some of the rationale behind this optimization's incl=
usion. Bloat is a major design constraint.<br><br>On Thursday, January 17, =
2019 at 8:06:25 AM UTC-8, Dilip R wrote:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><div dir=3D"ltr">I am just writing to=C2=A0+1 this. I have long w=
ondered why there is no int overload<br>for the pow function but wasn't=
confident enough of asking here fearing that<br>I would've missed some=
thing blindingly obvious.<div><br></div><div>Thanks Joel for taking that ba=
ton.</div></div>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d0809e24-10f9-4def-a95a-7756424caf02%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d0809e24-10f9-4def-a95a-7756424caf02=
%40isocpp.org</a>.<br />
------=_Part_1035_1172686801.1547835447667--
------=_Part_1034_616440545.1547835447667--
.
Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Fri, 18 Jan 2019 14:38:49 -0800 (PST)
Raw View
------=_Part_1127_813155791.1547851129276
Content-Type: multipart/alternative;
boundary="----=_Part_1128_1455883637.1547851129277"
------=_Part_1128_1455883637.1547851129277
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Thursday, January 17, 2019 at 11:02:13 AM UTC-5, joel.g....@gmail.com=20
wrote:
>
> As of C++11, per overload 7 of the 'pow' function (
> https://en.cppreference.com/w/cpp/numeric/math/pow), integral types can=
=20
> be used as parameters, but they will be cast to double before calculation=
..=20
> I believe that an integral-specific overload should be made, which makes=
=20
> use of faster integer-operations available to CPUs.
>
> As a disclaimer, I am still a rather inexperienced programmer (College=20
> Sophomore), and I my have some misunderstands as to what would fall under=
=20
> the ISO standard and what would fall under compiler-implementations. As I=
=20
> understand it, the line about "If any argument has integral type, it is=
=20
> cast to double." is a component of the ISO standard.
>
> As stated on isocpp.org's FAQ section, this idea is based on existing=20
> practices. As discussed here (
> https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-=
exponent-in-the-standard-c-libraries),=20
> multiple implementations of this function have been made on a per-user=20
> basis, due to its general simplicity and lack of inclusion in previous=20
> standards. In the below testing, I created a function using x86 asm. It i=
s=20
> worth noting that even with more standard C++ approaches, as testified in=
=20
> the stackoverflow discussion above, a significant performance improvement=
=20
> can be made.
>
> For the sake of brevity, the data-table and source have been withheld, bu=
t=20
> if it is relevant to the conversation, I would be more than willing to=20
> provide them.
>
> Do any of you agree that this is a useful addition to the C++ standards?
>
> *Performance Testing:*
> Tests were run on an Intel Core i3 6006U @ 2.0GHz
>
> Custom Function (VS 2017) :=20
> __declspec(naked) __int32 __fastcall powi(__int32 base, __int32 exp) {=20
> __asm { ... } }
>
> Test Range:
>
> base: [-46340, 46340] (int-truncation of the sqrt of MAX_INT)
>
> exp: [-19, 19] (highest power of 3, that does not overflow the int type)
>
>
> Results: (Approx. x20 avg. improvement)
>
> [image: Untitled.png]
>
>
>
I am skeptical of this graph's reality. It looks too neat to me, with an=20
identical dip at n^0 and a constant gap between the two lines even on a log=
=20
scale. (I could believe a constant gap on a linear scale, if what we were=
=20
witnessing is the constant cost of two int-to-double conversions. But not a=
=20
constant gap on a log scale!)
Do you have a link to your exact test cases and the software that produced=
=20
this graph, such that other people could reproduce your experiment from=20
scratch on their own hardware?
Another thing that makes me skeptical of this graph is the weirdly constant=
=20
and very low latencies for n^-19 through n^-1 (which are displayed as -n^19=
=20
to -n^1 on the X-axis, but I assume that's a typo). Solving n^-19 (a.k.a.=
=20
1/n^19) in integers is just "return (n =3D=3D 1) ? 1 : (n =3D=3D -1) ? -1 :=
0;",=20
right? Whereas solving n^-19 in floating-point ought to require the exact=
=20
same "log, multiply, exp" that would be required for n^19.
As for adding a new overload of std::pow =E2=80=94 no, you'll never get awa=
y with=20
that.
double x =3D std::pow(10, 20);
currently has well-defined behavior =E2=80=94 it yields 1e+20. You're prop=
osing to=20
make it have undefined behavior instead. I don't think that's going to fly=
..
You'd have better luck asking GCC and Clang to optimize `__builtin_pow` for=
=20
small integers. Which I think they might already do?
https://godbolt.org/z/7lPPLf
Looks like maybe they special-case std::pow(1, n) but nothing else.
HTH,
Arthur
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/c5128f98-b764-4576-90fc-eda8d40d980e%40isocpp.or=
g.
------=_Part_1128_1455883637.1547851129277
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, January 17, 2019 at 11:02:13 AM UTC-5, joel.g=
.....@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">As of C++11, per overload 7 of the 'pow' function (<a href=
=3D"https://en.cppreference.com/w/cpp/numeric/math/pow" target=3D"_blank" r=
el=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.com/url?=
q\x3dhttps%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fnumeric%2Fmath%2Fpow\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF58qoLigGYXuRNd7iC7b_Cp3V1aA';retu=
rn true;" onclick=3D"this.href=3D'https://www.google.com/url?q\x3dhttps=
%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fnumeric%2Fmath%2Fpow\x26sa\x3dD\x2=
6sntz\x3d1\x26usg\x3dAFQjCNF58qoLigGYXuRNd7iC7b_Cp3V1aA';return true;">=
https://en.cppreference.com/<wbr>w/cpp/numeric/math/pow</a>), integral type=
s can be used as parameters, but they will be cast to double before calcula=
tion. I believe that an integral-specific overload should be made, which ma=
kes use of faster integer-operations available to CPUs.<div><br></div><div>=
As a disclaimer, I am still a rather inexperienced programmer (College Soph=
omore), and I my have some misunderstands as to what would fall under the I=
SO standard and what would fall under compiler-implementations. As I unders=
tand it, the line about "<span style=3D"color:rgb(0,0,0);font-family:D=
ejaVuSans,"DejaVu Sans",arial,sans-serif;font-size:12.8px">If any=
argument has integral type,=C2=A0</span><span style=3D"color:rgb(0,0,0);fo=
nt-family:DejaVuSans,"DejaVu Sans",arial,sans-serif;font-size:12.=
8px">it is cast to double." is a component of the ISO standard.</span>=
</div><div><span style=3D"color:rgb(0,0,0);font-family:DejaVuSans,"Dej=
aVu Sans",arial,sans-serif;font-size:12.8px"><br></span></div><div sty=
le=3D"text-indent:0px"><span style=3D"color:rgb(0,0,0);font-family:DejaVuSa=
ns,"DejaVu Sans",arial,sans-serif;font-size:12.8px">As stated on =
<a href=3D"http://isocpp.org" target=3D"_blank" rel=3D"nofollow" onmousedow=
n=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fisocpp.or=
g\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHaIcX84r8AUHgx9Q4pR00LZ1llsQ'=
;return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dh=
ttp%3A%2F%2Fisocpp.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHaIcX84r8AUH=
gx9Q4pR00LZ1llsQ';return true;">isocpp.org</a>'s FAQ section, this =
idea is based on existing practices. As discussed here (</span><font color=
=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><a href=3D=
"https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int-e=
xponent-in-the-standard-c-libraries" style=3D"font-size:12.8px" target=3D"_=
blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.=
com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F2398442%2Fwhy-is=
nt-int-powint-base-int-exponent-in-the-standard-c-libraries\x26sa\x3dD\x26s=
ntz\x3d1\x26usg\x3dAFQjCNHWzh0WCiD6kSmtYt-R3r1LOBIlPw';return true;" on=
click=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fsta=
ckoverflow.com%2Fquestions%2F2398442%2Fwhy-isnt-int-powint-base-int-exponen=
t-in-the-standard-c-libraries\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHWzh0=
WCiD6kSmtYt-R3r1LOBIlPw';return true;">https://stackoverflow.com/<wbr>q=
uestions/2398442/why-isnt-<wbr>int-powint-base-int-exponent-<wbr>in-the-sta=
ndard-c-libraries</a><span style=3D"font-size:12.8px">), multiple implement=
ations=C2=A0of this function have been made on a per-user basis, due to its=
general simplicity and lack of inclusion in previous standards. In the bel=
ow testing, I created a function using x86 asm. It is worth noting that eve=
n with more standard C++ approaches, as testified in the stackoverflow disc=
ussion above, a significant performance improvement can be made.</span></fo=
nt></div><div style=3D"text-indent:0px"><font color=3D"#000000" face=3D"Dej=
aVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"font-size:12.8px"><=
br></span></font></div><div style=3D"text-indent:0px"><font color=3D"#00000=
0" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"font-=
size:12.8px">For the sake of brevity, the data-table and source have been w=
ithheld, but if it is relevant=C2=A0to the conversation, I would be more th=
an willing to provide them.</span></font></div><div style=3D"text-indent:0p=
x"><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-ser=
if"><span style=3D"font-size:12.8px"><br></span></font></div><div style=3D"=
text-indent:0px"><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, a=
rial, sans-serif"><span style=3D"font-size:12.8px">Do any of you agree that=
this is a useful addition to the C++ standards?</span></font></div><div><b=
><br></b></div><div><b>Performance Testing:</b></div><div><div><font size=
=3D"1">Tests were run on an Intel Core i3 6006U @ 2.0GHz</font></div><div><=
br></div><div>Custom Function (VS 2017) : <div style=3D"background-color:rg=
b(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-widt=
h:1px"><code><div><span style=3D"color:#000">__declspec</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">naked</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> __int32 __fastcall powi=
</span><span style=3D"color:#660">(</span><span style=3D"color:#000">__int3=
2 </span><span style=3D"color:#008">base</span><span style=3D"color:#660">,=
</span><span style=3D"color:#000"> __int32 exp</span><span style=3D"color:#=
660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
{</span><span style=3D"color:#000"> __asm </span><span style=3D"color:#660"=
>{</span><span style=3D"color:#000"> </span><span style=3D"color:#660">...<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">}</span></di=
v></code></div></div><div><br></div><div>Test Range:</div><blockquote style=
=3D"margin:0 0 0 40px;border:none;padding:0px"><div>base: [-46340, 46340]=
=C2=A0 (int-truncation of the sqrt of MAX_INT)</div></blockquote><blockquot=
e style=3D"margin:0 0 0 40px;border:none;padding:0px">exp: [-19, 19] (highe=
st power of 3, that does not overflow the int type)</blockquote><div><br></=
div><div>Results: (Approx. x20 avg. improvement)</div><p style=3D"text-alig=
n:left;clear:both"><img src=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/attach/13eb89bedb9e8f/Untitled.png?part=3D0.1&view=3D1&a=
mp;authuser=3D0" alt=3D"Untitled.png" width=3D"320" height=3D"183" style=3D=
"margin-left:1em;margin-right:1em"></p><p style=3D"text-align:left;clear:bo=
th"><br></p></div></div></blockquote><div><br></div><div>I am skeptical of =
this graph's reality. It looks too neat to me, with an identical dip at=
n^0 and a constant gap between the two lines even on a log scale. (I could=
believe a constant gap on a linear scale, if what we were witnessing is th=
e constant cost of two int-to-double conversions. But not a constant gap on=
a log scale!)</div><div>Do you have a link to your exact test cases and th=
e software that produced this graph, such that other people could reproduce=
your experiment from scratch on their own hardware?</div><div><br></div><d=
iv>Another thing that makes me skeptical of this graph is the weirdly const=
ant and very low latencies for n^-19 through n^-1 (which are displayed as -=
n^19 to -n^1 on the X-axis, but I assume that's a typo). =C2=A0Solving =
n^-19 (a.k.a. 1/n^19) in integers is just "return (n =3D=3D 1) ? 1 : (=
n =3D=3D -1) ? -1 : 0;", right? Whereas solving n^-19 in floating-poin=
t ought to require the exact same "log, multiply, exp" that would=
be required for n^19.</div><div><br></div><div>As for adding a new overloa=
d of std::pow =E2=80=94 no, you'll never get away with that.</div><div>=
<br></div><div>=C2=A0 =C2=A0 double x =3D std::pow(10, 20);<br></div><div><=
br></div><div>currently has well-defined behavior =E2=80=94 it yields 1e+20=
.. =C2=A0You're proposing to make it have undefined behavior instead. =
=C2=A0I don't think that's going to fly.</div><div><br></div><div>Y=
ou'd have better luck asking GCC and Clang to optimize `__builtin_pow` =
for small integers. Which I think they might already do?</div><div><a href=
=3D"https://godbolt.org/z/7lPPLf">https://godbolt.org/z/7lPPLf</a><br></div=
><div>Looks like maybe they special-case std::pow(1, n) but nothing else.</=
div><div><br></div><div>HTH,</div><div>Arthur</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/c5128f98-b764-4576-90fc-eda8d40d980e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c5128f98-b764-4576-90fc-eda8d40d980e=
%40isocpp.org</a>.<br />
------=_Part_1128_1455883637.1547851129277--
------=_Part_1127_813155791.1547851129276--
.
Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Fri, 18 Jan 2019 15:42:18 -0800 (PST)
Raw View
------=_Part_1095_2073383179.1547854938862
Content-Type: text/plain; charset="UTF-8"
I agree on that - but I also dislike like the unnecessary abbreviation "pow", so I'd propose a templated function std::power, maybe with a default for unsigned integral powers if T operator*(T const&, T const&) exists.
Even better, an operator for it instead (e.g. ^^, as ** introduces ambiguities).
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e9d08680-2afe-45b3-a95c-ac9ddc2ef386%40isocpp.org.
------=_Part_1095_2073383179.1547854938862--
.
Author: joel.g.hemphill@gmail.com
Date: Fri, 18 Jan 2019 17:12:17 -0800 (PST)
Raw View
------=_Part_1242_234203149.1547860338011
Content-Type: multipart/alternative;
boundary="----=_Part_1243_674698673.1547860338012"
------=_Part_1243_674698673.1547860338012
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
The case you pointed out of using the double-type of the return for=20
'pow(int, int)' would be a major concern. Perhaps a workaround would be the=
=20
requirement of an explicit template? i.e. "double x =3D std::pow(10, 20);"=
=20
would use overload 7, whereas "std::pow<int, int>(10, 20)" would return=20
int? Alternatively, as Jake Arkinstall suggested, a new syntax for 'pow' as=
=20
'power' might be in order, in which case, such contingencies wouldn't be as=
=20
large a concern. I would also argue that the above code segment is poor=20
practice, as it is relying upon the pow function to convert the two=20
integers to doubles. More explicit typing would be preferred in most coding=
=20
environments. Another solution, as is implemented with powl and powf, is to=
=20
use a single-letter abbreviation to explicitly define the types used. i.e.=
=20
powi.
As for the graph; I mentioned in a reply to my original posting that I have=
=20
since found an issue with the testing method I used for graphing the=20
execution times for pow and powi. I have since done other tests as shown=20
below [avg. of 20000 runs for powi, and 500 for pow (since the execution is=
=20
longer, I decided to neglect the sample-count somewhat)]:
[image: Untitled2.png]
As you can see, powi does experience a gradual increase in execution length=
=20
with the increasing exponents (since it needs to do at worst [if an=20
implementation were to use a simple linear approach, O(n) multiplications])=
..
While the normal method does appear to be O(1), the execution lengths for=
=20
floating-point operations are significant enough to negate those benefits=
=20
with the ranges of 32 and 64-bit integer types.
Also below, I have included the collected data, which was gathered using=20
"std::chrono::high_resolution_clock::now()" surrounding for-loops executing=
=20
the functions within the base-value ranges for each exponent.
Power STL Custom=20
> -19 152.4881 5.922077=20
> -18 156.3487 5.497594=20
> -17 141.8481 5.546061=20
> -16 145.8614 5.683295=20
> -15 145.8326 6.041384=20
> -14 149.2215 5.701708=20
> -13 145.5323 5.59141=20
> -12 149.3403 5.602157=20
> -11 146.3427 5.974374=20
> -10 152.5245 6.180647=20
> -9 146.4068 5.772337=20
> -8 143.3287 5.782097=20
> -7 152.735 5.678149=20
> -6 146.4267 5.743723=20
> -5 145.5064 5.750488=20
> -4 150.1708 5.772985=20
> -3 142.524 6.569755=20
> -2 140.4772 5.600695=20
> -1 143.6424 6.281142=20
> 0 107.1507 3.854533=20
> 1 140.658 6.386001=20
> 2 147.3853 6.076429=20
> 3 146.9267 8.102243=20
> 4 141.4524 6.984409=20
> 5 136.9645 10.44516=20
> 6 139.3443 8.883989=20
> 7 142.125 7.988396=20
> 8 141.0955 7.625333=20
> 9 140.6131 12.97227=20
> 10 138.1168 11.3224=20
> 11 143.1305 10.61643=20
> 12 139.4992 10.38626=20
> 13 141.5211 11.2896=20
> 14 141.0866 10.22915=20
> 15 140.7223 9.948738=20
> 16 139.7512 9.173968=20
> 17 138.1409 15.03408=20
> 18 141.6834 13.97868=20
> 19 153.7554 14.77899=20
On Friday, January 18, 2019 at 2:38:49 PM UTC-8, Arthur O'Dwyer wrote:
>
> On Thursday, January 17, 2019 at 11:02:13 AM UTC-5, joel.g....@gmail.com=
=20
> wrote:
>>
>> As of C++11, per overload 7 of the 'pow' function (
>> https://en.cppreference.com/w/cpp/numeric/math/pow), integral types can=
=20
>> be used as parameters, but they will be cast to double before calculatio=
n.=20
>> I believe that an integral-specific overload should be made, which makes=
=20
>> use of faster integer-operations available to CPUs.
>>
>> As a disclaimer, I am still a rather inexperienced programmer (College=
=20
>> Sophomore), and I my have some misunderstands as to what would fall unde=
r=20
>> the ISO standard and what would fall under compiler-implementations. As =
I=20
>> understand it, the line about "If any argument has integral type, it is=
=20
>> cast to double." is a component of the ISO standard.
>>
>> As stated on isocpp.org's FAQ section, this idea is based on existing=20
>> practices. As discussed here (
>> https://stackoverflow.com/questions/2398442/why-isnt-int-powint-base-int=
-exponent-in-the-standard-c-libraries),=20
>> multiple implementations of this function have been made on a per-user=
=20
>> basis, due to its general simplicity and lack of inclusion in previous=
=20
>> standards. In the below testing, I created a function using x86 asm. It =
is=20
>> worth noting that even with more standard C++ approaches, as testified i=
n=20
>> the stackoverflow discussion above, a significant performance improvemen=
t=20
>> can be made.
>>
>> For the sake of brevity, the data-table and source have been withheld,=
=20
>> but if it is relevant to the conversation, I would be more than willing =
to=20
>> provide them.
>>
>> Do any of you agree that this is a useful addition to the C++ standards?
>>
>> *Performance Testing:*
>> Tests were run on an Intel Core i3 6006U @ 2.0GHz
>>
>> Custom Function (VS 2017) :=20
>> __declspec(naked) __int32 __fastcall powi(__int32 base, __int32 exp) {=
=20
>> __asm { ... } }
>>
>> Test Range:
>>
>> base: [-46340, 46340] (int-truncation of the sqrt of MAX_INT)
>>
>> exp: [-19, 19] (highest power of 3, that does not overflow the int type)
>>
>>
>> Results: (Approx. x20 avg. improvement)
>>
>> [image: Untitled.png]
>>
>>
>>
> I am skeptical of this graph's reality. It looks too neat to me, with an=
=20
> identical dip at n^0 and a constant gap between the two lines even on a l=
og=20
> scale. (I could believe a constant gap on a linear scale, if what we were=
=20
> witnessing is the constant cost of two int-to-double conversions. But not=
a=20
> constant gap on a log scale!)
> Do you have a link to your exact test cases and the software that produce=
d=20
> this graph, such that other people could reproduce your experiment from=
=20
> scratch on their own hardware?
>
> Another thing that makes me skeptical of this graph is the weirdly=20
> constant and very low latencies for n^-19 through n^-1 (which are display=
ed=20
> as -n^19 to -n^1 on the X-axis, but I assume that's a typo). Solving n^-=
19=20
> (a.k.a. 1/n^19) in integers is just "return (n =3D=3D 1) ? 1 : (n =3D=3D =
-1) ? -1 :=20
> 0;", right? Whereas solving n^-19 in floating-point ought to require the=
=20
> exact same "log, multiply, exp" that would be required for n^19.
>
> As for adding a new overload of std::pow =E2=80=94 no, you'll never get a=
way with=20
> that.
>
> double x =3D std::pow(10, 20);
>
> currently has well-defined behavior =E2=80=94 it yields 1e+20. You're pr=
oposing=20
> to make it have undefined behavior instead. I don't think that's going t=
o=20
> fly.
>
> You'd have better luck asking GCC and Clang to optimize `__builtin_pow`=
=20
> for small integers. Which I think they might already do?
> https://godbolt.org/z/7lPPLf
> Looks like maybe they special-case std::pow(1, n) but nothing else.
>
> HTH,
> Arthur
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/1d2bd16a-c2f9-4baa-b2d3-4b0241de8992%40isocpp.or=
g.
------=_Part_1243_674698673.1547860338012
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The case you pointed out of using the double-type of the r=
eturn for 'pow(int, int)' would be a major concern. Perhaps a worka=
round would be the requirement of an explicit template? i.e. "double x=
=3D std::pow(10, 20);" would use overload 7, whereas "std::pow&l=
t;int, int>(10, 20)" would return int? Alternatively, as Jake Arkin=
stall suggested, a new syntax for 'pow' as 'power' might be=
in order, in which case, such contingencies wouldn't be as large a con=
cern. I would also argue that the above code segment is poor practice, as i=
t is relying upon the pow function to convert the two integers to doubles. =
More explicit typing would be preferred in most coding environments. Anothe=
r solution, as is implemented with powl and powf, is to use a single-letter=
abbreviation to explicitly define the types used. i.e. powi.<div><br></div=
><div>As for the graph; I mentioned in a reply to my original posting that =
I have since found an issue with the testing method I used for graphing the=
execution times for pow and powi. I have since done other tests as shown b=
elow [avg. of 20000 runs for powi, and 500 for pow (since the execution is =
longer, I decided to neglect the sample-count somewhat)]:</div><div><br></d=
iv><p class=3D"separator" style=3D"text-align: left; clear: both;"><img src=
=3D"cid:48451991-147f-4022-b5a2-fd68fb1a3cbe" alt=3D"Untitled2.png" width=
=3D"320" height=3D"183" style=3D"margin-left: 1em; margin-right: 1em;"></p>=
<p class=3D"separator" style=3D"text-align: left; clear: both;"><br></p><p =
class=3D"separator" style=3D"text-align: left; clear: both;">As you can see=
, powi does experience a gradual increase in execution length with the incr=
easing exponents (since it needs to do at worst [if an implementation were =
to use a simple linear approach, O(n) multiplications]).</p><p class=3D"sep=
arator" style=3D"text-align: left; clear: both;"><br></p><p class=3D"separa=
tor" style=3D"text-align: left; clear: both;">While the normal method does =
appear to be O(1), the execution lengths for floating-point operations are =
significant enough to negate those benefits with the ranges of 32 and 64-bi=
t integer types.</p><p class=3D"separator" style=3D"text-align: left; clear=
: both;"><br></p><p class=3D"separator" style=3D"text-align: left; clear: b=
oth;">Also below, I have included the collected data, which was gathered us=
ing "std::chrono::high_resolution_clock::now()" surrounding for-l=
oops executing the functions within the base-value ranges for each exponent=
..</p><p class=3D"separator" style=3D"text-align: left; clear: both;"><br></=
p><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; bor=
der-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><table border=
=3D"0" cellpadding=3D"0" cellspacing=3D"0" width=3D"175" style=3D"border-co=
llapse:
collapse;width:131pt">
<colgroup><col width=3D"47" style=3D"mso-width-source:userset;mso-width-al=
t:1718;width:35pt">
<col width=3D"64" span=3D"2" style=3D"width:48pt">
</colgroup><tbody><tr height=3D"18" style=3D"mso-height-source:userset;hei=
ght:13.5pt">
<td height=3D"18" width=3D"47" style=3D"height:13.5pt;width:35pt">Power</=
td>
<td width=3D"64" style=3D"width:48pt">STL</td>
<td width=3D"64" style=3D"width:48pt">Custom</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-19</td>
<td align=3D"right">152.4881</td>
<td align=3D"right">5.922077</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-18</td>
<td align=3D"right">156.3487</td>
<td align=3D"right">5.497594</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-17</td>
<td align=3D"right">141.8481</td>
<td align=3D"right">5.546061</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-16</td>
<td align=3D"right">145.8614</td>
<td align=3D"right">5.683295</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-15</td>
<td align=3D"right">145.8326</td>
<td align=3D"right">6.041384</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-14</td>
<td align=3D"right">149.2215</td>
<td align=3D"right">5.701708</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-13</td>
<td align=3D"right">145.5323</td>
<td align=3D"right">5.59141</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-12</td>
<td align=3D"right">149.3403</td>
<td align=3D"right">5.602157</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-11</td>
<td align=3D"right">146.3427</td>
<td align=3D"right">5.974374</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-10</td>
<td align=3D"right">152.5245</td>
<td align=3D"right">6.180647</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-9</td>
<td align=3D"right">146.4068</td>
<td align=3D"right">5.772337</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-8</td>
<td align=3D"right">143.3287</td>
<td align=3D"right">5.782097</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-7</td>
<td align=3D"right">152.735</td>
<td align=3D"right">5.678149</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-6</td>
<td align=3D"right">146.4267</td>
<td align=3D"right">5.743723</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-5</td>
<td align=3D"right">145.5064</td>
<td align=3D"right">5.750488</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-4</td>
<td align=3D"right">150.1708</td>
<td align=3D"right">5.772985</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-3</td>
<td align=3D"right">142.524</td>
<td align=3D"right">6.569755</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-2</td>
<td align=3D"right">140.4772</td>
<td align=3D"right">5.600695</td>
</tr>
<tr height=3D"20" style=3D"mso-height-source:userset;height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">-1</td>
<td align=3D"right">143.6424</td>
<td align=3D"right">6.281142</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">0</td>
<td align=3D"right">107.1507</td>
<td align=3D"right">3.854533</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">1</td>
<td align=3D"right">140.658</td>
<td align=3D"right">6.386001</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">2</td>
<td align=3D"right">147.3853</td>
<td align=3D"right">6.076429</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">3</td>
<td align=3D"right">146.9267</td>
<td align=3D"right">8.102243</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">4</td>
<td align=3D"right">141.4524</td>
<td align=3D"right">6.984409</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">5</td>
<td align=3D"right">136.9645</td>
<td align=3D"right">10.44516</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">6</td>
<td align=3D"right">139.3443</td>
<td align=3D"right">8.883989</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">7</td>
<td align=3D"right">142.125</td>
<td align=3D"right">7.988396</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">8</td>
<td align=3D"right">141.0955</td>
<td align=3D"right">7.625333</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">9</td>
<td align=3D"right">140.6131</td>
<td align=3D"right">12.97227</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">10</td>
<td align=3D"right">138.1168</td>
<td align=3D"right">11.3224</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">11</td>
<td align=3D"right">143.1305</td>
<td align=3D"right">10.61643</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">12</td>
<td align=3D"right">139.4992</td>
<td align=3D"right">10.38626</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">13</td>
<td align=3D"right">141.5211</td>
<td align=3D"right">11.2896</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">14</td>
<td align=3D"right">141.0866</td>
<td align=3D"right">10.22915</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">15</td>
<td align=3D"right">140.7223</td>
<td align=3D"right">9.948738</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">16</td>
<td align=3D"right">139.7512</td>
<td align=3D"right">9.173968</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">17</td>
<td align=3D"right">138.1409</td>
<td align=3D"right">15.03408</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">18</td>
<td align=3D"right">141.6834</td>
<td align=3D"right">13.97868</td>
</tr>
<tr height=3D"20" style=3D"height:15.0pt">
<td height=3D"20" align=3D"right" style=3D"height:15.0pt">19</td>
<td align=3D"right">153.7554</td>
<td align=3D"right">14.77899</td>
</tr></tbody></table></blockquote><div><br><br>On Friday, January 18, 2019=
at 2:38:49 PM UTC-8, Arthur O'Dwyer wrote:<blockquote class=3D"gmail_q=
uote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pad=
ding-left: 1ex;"><div dir=3D"ltr">On Thursday, January 17, 2019 at 11:02:13=
AM UTC-5, <a>joel.g....@gmail.com</a> wrote:<blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr">As of C++11, per overload 7 of the 'pow'=
function (<a href=3D"https://en.cppreference.com/w/cpp/numeric/math/pow" r=
el=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'https://w=
ww.google.com/url?q\x3dhttps%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fnumeri=
c%2Fmath%2Fpow\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF58qoLigGYXuRNd7iC7b=
_Cp3V1aA';return true;" onclick=3D"this.href=3D'https://www.google.=
com/url?q\x3dhttps%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fnumeric%2Fmath%2=
Fpow\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF58qoLigGYXuRNd7iC7b_Cp3V1aA&#=
39;;return true;">https://en.cppreference.com/<wbr>w/cpp/numeric/math/pow</=
a>), integral types can be used as parameters, but they will be cast to dou=
ble before calculation. I believe that an integral-specific overload should=
be made, which makes use of faster integer-operations available to CPUs.<d=
iv><br></div><div>As a disclaimer, I am still a rather inexperienced progra=
mmer (College Sophomore), and I my have some misunderstands as to what woul=
d fall under the ISO standard and what would fall under compiler-implementa=
tions. As I understand it, the line about "<span style=3D"color:rgb(0,=
0,0);font-family:DejaVuSans,"DejaVu Sans",arial,sans-serif;font-s=
ize:12.8px">If any argument has integral type,=C2=A0</span><span style=3D"c=
olor:rgb(0,0,0);font-family:DejaVuSans,"DejaVu Sans",arial,sans-s=
erif;font-size:12.8px">it is cast to double." is a component of the IS=
O standard.</span></div><div><span style=3D"color:rgb(0,0,0);font-family:De=
jaVuSans,"DejaVu Sans",arial,sans-serif;font-size:12.8px"><br></s=
pan></div><div style=3D"text-indent:0px"><span style=3D"color:rgb(0,0,0);fo=
nt-family:DejaVuSans,"DejaVu Sans",arial,sans-serif;font-size:12.=
8px">As stated on <a href=3D"http://isocpp.org" rel=3D"nofollow" target=3D"=
_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp=
%3A%2F%2Fisocpp.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHaIcX84r8AUHgx9=
Q4pR00LZ1llsQ';return true;" onclick=3D"this.href=3D'http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fisocpp.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3d=
AFQjCNHaIcX84r8AUHgx9Q4pR00LZ1llsQ';return true;">isocpp.org</a>'s =
FAQ section, this idea is based on existing practices. As discussed here (<=
/span><font color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-=
serif"><a href=3D"https://stackoverflow.com/questions/2398442/why-isnt-int-=
powint-base-int-exponent-in-the-standard-c-libraries" style=3D"font-size:12=
..8px" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'ht=
tps://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2=
F2398442%2Fwhy-isnt-int-powint-base-int-exponent-in-the-standard-c-librarie=
s\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHWzh0WCiD6kSmtYt-R3r1LOBIlPw'=
;return true;" onclick=3D"this.href=3D'https://www.google.com/url?q\x3d=
https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2398442%2Fwhy-isnt-int-powint=
-base-int-exponent-in-the-standard-c-libraries\x26sa\x3dD\x26sntz\x3d1\x26u=
sg\x3dAFQjCNHWzh0WCiD6kSmtYt-R3r1LOBIlPw';return true;">https://stackov=
erflow.com/<wbr>questions/2398442/why-isnt-<wbr>int-powint-base-int-exponen=
t-<wbr>in-the-standard-c-libraries</a><span style=3D"font-size:12.8px">), m=
ultiple implementations=C2=A0of this function have been made on a per-user =
basis, due to its general simplicity and lack of inclusion in previous stan=
dards. In the below testing, I created a function using x86 asm. It is wort=
h noting that even with more standard C++ approaches, as testified in the s=
tackoverflow discussion above, a significant performance improvement can be=
made.</span></font></div><div style=3D"text-indent:0px"><font color=3D"#00=
0000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"fo=
nt-size:12.8px"><br></span></font></div><div style=3D"text-indent:0px"><fon=
t color=3D"#000000" face=3D"DejaVuSans, DejaVu Sans, arial, sans-serif"><sp=
an style=3D"font-size:12.8px">For the sake of brevity, the data-table and s=
ource have been withheld, but if it is relevant=C2=A0to the conversation, I=
would be more than willing to provide them.</span></font></div><div style=
=3D"text-indent:0px"><font color=3D"#000000" face=3D"DejaVuSans, DejaVu San=
s, arial, sans-serif"><span style=3D"font-size:12.8px"><br></span></font></=
div><div style=3D"text-indent:0px"><font color=3D"#000000" face=3D"DejaVuSa=
ns, DejaVu Sans, arial, sans-serif"><span style=3D"font-size:12.8px">Do any=
of you agree that this is a useful addition to the C++ standards?</span></=
font></div><div><b><br></b></div><div><b>Performance Testing:</b></div><div=
><div><font size=3D"1">Tests were run on an Intel Core i3 6006U @ 2.0GHz</f=
ont></div><div><br></div><div>Custom Function (VS 2017) : <div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px"><code><div><span style=3D"color:#000">__declspec</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#000">naked</spa=
n><span style=3D"color:#660">)</span><span style=3D"color:#000"> __int32 __=
fastcall powi</span><span style=3D"color:#660">(</span><span style=3D"color=
:#000">__int32 </span><span style=3D"color:#008">base</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> __int32 exp</span><span sty=
le=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">{</span><span style=3D"color:#000"> __asm </span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">...</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">}</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">}</span></div></code></div></div><div><br></div><div>Test Range:</div><b=
lockquote style=3D"margin:0 0 0 40px;border:none;padding:0px"><div>base: [-=
46340, 46340]=C2=A0 (int-truncation of the sqrt of MAX_INT)</div></blockquo=
te><blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px">exp: [-1=
9, 19] (highest power of 3, that does not overflow the int type)</blockquot=
e><div><br></div><div>Results: (Approx. x20 avg. improvement)</div><p style=
=3D"text-align:left;clear:both"><img src=3D"https://groups.google.com/a/iso=
cpp.org/group/std-proposals/attach/13eb89bedb9e8f/Untitled.png?part=3D0.1&a=
mp;view=3D1&authuser=3D0" alt=3D"Untitled.png" width=3D"320" height=3D"=
183" style=3D"margin-left:1em;margin-right:1em"></p><p style=3D"text-align:=
left;clear:both"><br></p></div></div></blockquote><div><br></div><div>I am =
skeptical of this graph's reality. It looks too neat to me, with an ide=
ntical dip at n^0 and a constant gap between the two lines even on a log sc=
ale. (I could believe a constant gap on a linear scale, if what we were wit=
nessing is the constant cost of two int-to-double conversions. But not a co=
nstant gap on a log scale!)</div><div>Do you have a link to your exact test=
cases and the software that produced this graph, such that other people co=
uld reproduce your experiment from scratch on their own hardware?</div><div=
><br></div><div>Another thing that makes me skeptical of this graph is the =
weirdly constant and very low latencies for n^-19 through n^-1 (which are d=
isplayed as -n^19 to -n^1 on the X-axis, but I assume that's a typo). =
=C2=A0Solving n^-19 (a.k.a. 1/n^19) in integers is just "return (n =3D=
=3D 1) ? 1 : (n =3D=3D -1) ? -1 : 0;", right? Whereas solving n^-19 in=
floating-point ought to require the exact same "log, multiply, exp&qu=
ot; that would be required for n^19.</div><div><br></div><div>As for adding=
a new overload of std::pow =E2=80=94 no, you'll never get away with th=
at.</div><div><br></div><div>=C2=A0 =C2=A0 double x =3D std::pow(10, 20);<b=
r></div><div><br></div><div>currently has well-defined behavior =E2=80=94 i=
t yields 1e+20. =C2=A0You're proposing to make it have undefined behavi=
or instead. =C2=A0I don't think that's going to fly.</div><div><br>=
</div><div>You'd have better luck asking GCC and Clang to optimize `__b=
uiltin_pow` for small integers. Which I think they might already do?</div><=
div><a href=3D"https://godbolt.org/z/7lPPLf" target=3D"_blank" rel=3D"nofol=
low" onmousedown=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%=
3A%2F%2Fgodbolt.org%2Fz%2F7lPPLf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF7=
DHgtuBimpaJqB4kbFlq8qen6_w';return true;" onclick=3D"this.href=3D'h=
ttps://www.google.com/url?q\x3dhttps%3A%2F%2Fgodbolt.org%2Fz%2F7lPPLf\x26sa=
\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF7DHgtuBimpaJqB4kbFlq8qen6_w';return=
true;">https://godbolt.org/z/7lPPLf</a><br></div><div>Looks like maybe the=
y special-case std::pow(1, n) but nothing else.</div><div><br></div><div>HT=
H,</div><div>Arthur</div></div></blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1d2bd16a-c2f9-4baa-b2d3-4b0241de8992%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1d2bd16a-c2f9-4baa-b2d3-4b0241de8992=
%40isocpp.org</a>.<br />
------=_Part_1243_674698673.1547860338012--
------=_Part_1242_234203149.1547860338011
Content-Type: image/png; name=Untitled2.png
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=Untitled2.png
X-Attachment-Id: 48451991-147f-4022-b5a2-fd68fb1a3cbe
Content-ID: <48451991-147f-4022-b5a2-fd68fb1a3cbe>
iVBORw0KGgoAAAANSUhEUgAAAfUAAAEfCAIAAADX9ciiAAAYyklEQVR42u3dXY8kV3nAcX8UfwWu
fJcrbgJSRHJBGAVF5gKhCHEDGgSy0MoRG0HA0eBIK4LIIuMQRzAQIDFaI8cKlm2W8Rteg9fGlrN4
gWSJvYbFXu+yMZtnpnqqq+utq6uqX6r691fJ7u2pl1Onu/7nqXNO13PLhQsXXgAAjItw+y3xv5sA
gHERbud3AOB3AAC/AwD4HQDA7wAAfgcAfgcA8DsAgN8BAPwOAOB3AAC/AwC/AwD4HQDA78CquLi/
u7Ozu39RTYDf+X143jm7tzPLZtmsULydnb2z4/L70TFytV9y2jOnf/j31X5QM6XU5PE7Nsc7NTrI
/SkRyyoV2sDvqyvOyr2Z+yDjn/nDl9bAasuZuD1ThsM3Oh1+9e0T+J3fV2/U7fZ7g9Nbu9+Pvms9
fwT8zu9o7vfjgGp6X3/8x9n76qIqClda2a5Lti60MHkP5bWQ7XIornZ8lEbRa/lfZs6kukKqylNa
UYWzrKiNRkesOon69Rb3e8kWM29lz2G+t+uboPpPoexY1V/I6rqd7DSzQvLXtK61Ffw+dr9nLor8
DXXr+D3nn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u5u0JP+q3MWAPwO5IU5TeAy9XhN3q71MU05dviyUaEK
qScBfscW+r3Cixvj95KiZss2fZ0G+flcY5mbk+PNDlOV7e8dv3e8gjYB/I6RGL5otA30e1koXub3
mfJmN8q2D+nrw7NP0xBPXmbuEwB+x3I5OH/5/Z9+4p0ffaSvJfb2wMGlguWn/mzt99//7NHX73r3
a596Ry9L7OraU99ZzO8zDVbleUxbgwap5AF+x7LoV+7J8q6PP1YTILeWXY9yT5bLd95WIvPa/pmb
076Y3V1+B79jk7nvwYu9+31v/6Wbs+OUWau1lt3Vh0/36/c3v3sye48x7Tc/fDUt5pHOS/S/s1PW
PzPtgeF38DtGS2YwMuO0WdmVrbEWpgOkhdLt7SdN1cwEz3TENNtzszMrfX4HvwMA+B0A+B0AwO8A
AH4HAPA7AIDfAQD8DgD8DgDgdwAAvwMA+B0AwO8AAH4HAH4HAPA7AGCD/P7iiy++AAAYF+H2/wfV
NRpJA0xVBAAAAABJRU5ErkJggg==
------=_Part_1242_234203149.1547860338011--
.
Author: joel.g.hemphill@gmail.com
Date: Fri, 18 Jan 2019 17:19:17 -0800 (PST)
Raw View
------=_Part_1174_980906168.1547860757552
Content-Type: multipart/alternative;
boundary="----=_Part_1175_950262710.1547860757553"
------=_Part_1175_950262710.1547860757553
Content-Type: text/plain; charset="UTF-8"
I think the idea of un-abbreviating pow would be a nice design shift,
though I am skeptical due to the amount of code which would be made
'legacy' by such a change. As for the operators... Those would need to be
introduced at the core-language level, and I don't think that it would be
an appropriate proposal here. As a side note here; I DO think it would be
an interesting shift in the core language to support user-defined
operators. It would be very difficult to define a consistent methodology,
but it would significantly improve the general readability of a good number
of object-interactions. For instance: operator::@(MyPointClass c)". Like I
said though, this really isn't the place for such ideas, as those would
need to happen at the lower-levels of C++.
On Friday, January 18, 2019 at 3:42:19 PM UTC-8, Jake Arkinstall wrote:
>
> I agree on that - but I also dislike like the unnecessary abbreviation
> "pow", so I'd propose a templated function std::power, maybe with a default
> for unsigned integral powers if T operator*(T const&, T const&) exists.
>
> Even better, an operator for it instead (e.g. ^^, as ** introduces
> ambiguities).
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a4ed51d9-36ac-462f-aafa-06478682140a%40isocpp.org.
------=_Part_1175_950262710.1547860757553
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think the idea of un-abbreviating pow would be a nice de=
sign shift, though I am skeptical due to the amount of code which would be =
made 'legacy' by such a change. As for the operators... Those would=
need to be introduced at the core-language level, and I don't think th=
at it would be an appropriate proposal here. As a side note here; I DO thin=
k it would be an interesting shift in the core language to support user-def=
ined operators. It would be very difficult to define a consistent methodolo=
gy, but it would significantly improve the general readability of a good nu=
mber of object-interactions. For instance: operator::@(MyPointClass c)"=
;. Like I said though, this really isn't the place for such ideas, as t=
hose would need to happen at the lower-levels of C++.<br><br>On Friday, Jan=
uary 18, 2019 at 3:42:19 PM UTC-8, Jake Arkinstall wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">I agree on that - but I also dislike like the u=
nnecessary abbreviation "pow", so I'd propose a templated fun=
ction std::power, maybe with a default for unsigned integral powers if T op=
erator*(T const&, T const&) exists.<p>Even better, an operator for =
it instead (e.g. ^^, as ** introduces ambiguities).</p></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a4ed51d9-36ac-462f-aafa-06478682140a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a4ed51d9-36ac-462f-aafa-06478682140a=
%40isocpp.org</a>.<br />
------=_Part_1175_950262710.1547860757553--
------=_Part_1174_980906168.1547860757552--
.
Author: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Date: Sat, 19 Jan 2019 01:59:07 -0500
Raw View
--0000000000009dc518057fca2a17
Content-Type: multipart/alternative; boundary="0000000000009dc516057fca2a16"
--0000000000009dc516057fca2a16
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Fri, Jan 18, 2019 at 8:12 PM <joel.g.hemphill@gmail.com> wrote:
> The case you pointed out of using the double-type of the return for
> 'pow(int, int)' would be a major concern. Perhaps a workaround would be t=
he
> requirement of an explicit template? i.e. "double x =3D std::pow(10, 20);=
"
> would use overload 7, whereas "std::pow<int, int>(10, 20)" would return
> int? Alternatively, as Jake Arkinstall suggested, a new syntax for 'pow' =
as
> 'power' might be in order, in which case, such contingencies wouldn't be =
as
> large a concern. I would also argue that the above code segment is poor
> practice, as it is relying upon the pow function to convert the two
> integers to doubles. More explicit typing would be preferred in most codi=
ng
> environments. Another solution, as is implemented with powl and powf, is =
to
> use a single-letter abbreviation to explicitly define the types used. i.e=
..
> powi.
>
> As for the graph; I mentioned in a reply to my original posting that I
> have since found an issue with the testing method I used for graphing the
> execution times for pow and powi. I have since done other tests as shown
> below [avg. of 20000 runs for powi, and 500 for pow (since the execution =
is
> longer, I decided to neglect the sample-count somewhat)]:
>
> [image: Untitled2.png]
>
> As you can see, powi does experience a gradual increase in execution
> length with the increasing exponents (since it needs to do at worst [if a=
n
> implementation were to use a simple linear approach, O(n) multiplications=
]).
>
But really O(lg n) multiplications, right?
That graph looks a lot better (flatter), but I'd still have to see the code
before I believe it. You say your data was
> gathered using "std::chrono::high_resolution_clock::now()" surrounding
for-loops executing the functions
which pointedly omits any reference to e.g. Google Benchmark
<https://github.com/google/benchmark> or ClobberMemory/DoNotOptimize. Which
suggests that your benchmark might not have been measuring anything
meaningful.
=E2=80=93Arthur
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CADvuK0LeMK-uYS5WPMEMxKjfGAA6TFybpFJD_Yqh12wkOP4=
FcQ%40mail.gmail.com.
--0000000000009dc516057fca2a16
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr">On Fri, Jan 18, 2019 at 8:12 PM <<a hr=
ef=3D"mailto:joel.g.hemphill@gmail.com">joel.g.hemphill@gmail.com</a>> w=
rote:<br></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote"=
style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:=
solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"=
>The case you pointed out of using the double-type of the return for 'p=
ow(int, int)' would be a major concern. Perhaps a workaround would be t=
he requirement of an explicit template? i.e. "double x =3D std::pow(10=
, 20);" would use overload 7, whereas "std::pow<int, int>(1=
0, 20)" would return int? Alternatively, as Jake Arkinstall suggested,=
a new syntax for 'pow' as 'power' might be in order, in wh=
ich case, such contingencies wouldn't be as large a concern. I would al=
so argue that the above code segment is poor practice, as it is relying upo=
n the pow function to convert the two integers to doubles. More explicit ty=
ping would be preferred in most coding environments. Another solution, as i=
s implemented with powl and powf, is to use a single-letter abbreviation to=
explicitly define the types used. i.e. powi.<div><br></div><div>As for the=
graph; I mentioned in a reply to my original posting that I have since fou=
nd an issue with the testing method I used for graphing the execution times=
for pow and powi. I have since done other tests as shown below [avg. of 20=
000 runs for powi, and 500 for pow (since the execution is longer, I decide=
d to neglect the sample-count somewhat)]:</div><div><br></div><p class=3D"g=
mail-m_1293241612643520167separator" style=3D"text-align:left;clear:both"><=
img src=3D"cid:48451991-147f-4022-b5a2-fd68fb1a3cbe" alt=3D"Untitled2.png" =
width=3D"320" height=3D"183" style=3D"margin-left: 1em; margin-right: 1em;"=
></p><p class=3D"gmail-m_1293241612643520167separator" style=3D"text-align:=
left;clear:both">As you can see, powi does experience a gradual increase in=
execution length with the increasing exponents (since it needs to do at wo=
rst [if an implementation were to use a simple linear approach, O(n) multip=
lications]).<br></p></div></blockquote><div>But really O(lg n) multiplicati=
ons, right?</div><div>That graph looks a lot better (flatter), but I'd =
still have to see the code before I believe it. You say your data was</div>=
<div><br></div><div>> gathered using "std::chrono::high_resolution_=
clock::now()" surrounding for-loops executing the functions</div><div>=
<br></div><div>which pointedly omits any reference to e.g. <a href=3D"https=
://github.com/google/benchmark">Google Benchmark</a> or ClobberMemory/DoNot=
Optimize. Which suggests that your benchmark might not have been measuring =
anything meaningful.</div><div><br></div><div>=E2=80=93Arthur</div></div></=
div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CADvuK0LeMK-uYS5WPMEMxKjfGAA6TFybpFJD=
_Yqh12wkOP4FcQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0LeMK-uYS5W=
PMEMxKjfGAA6TFybpFJD_Yqh12wkOP4FcQ%40mail.gmail.com</a>.<br />
--0000000000009dc516057fca2a16--
--0000000000009dc518057fca2a17
Content-Type: image/png; name="Untitled2.png"
Content-Disposition: inline; filename="Untitled2.png"
Content-Transfer-Encoding: base64
Content-ID: <48451991-147f-4022-b5a2-fd68fb1a3cbe>
X-Attachment-Id: 48451991-147f-4022-b5a2-fd68fb1a3cbe
iVBORw0KGgoAAAANSUhEUgAAAfUAAAEfCAIAAADX9ciiAAAYyklEQVR42u3dXY8kV3nAcX8UfwWu
fJcrbgJSRHJBGAVF5gKhCHEDGgSy0MoRG0HA0eBIK4LIIuMQRzAQIDFaI8cKlm2W8Rteg9fGlrN4
gWSJvYbFXu+yMZtnpnqqq+utq6uqX6r691fJ7u2pl1Onu/7nqXNO13PLhQsXXgAAjItw+y3xv5sA
gHERbud3AOB3AAC/AwD4HQDA7wAAfgcAfgcA8DsAgN8BAPwOAOB3AAC/AwC/AwD4HQDA78CquLi/
u7Ozu39RTYDf+X143jm7tzPLZtmsULydnb2z4/L70TFytV9y2jOnf/j31X5QM6XU5PE7Nsc7NTrI
/SkRyyoV2sDvqyvOyr2Z+yDjn/nDl9bAasuZuD1ThsM3Oh1+9e0T+J3fV2/U7fZ7g9Nbu9+Pvms9
fwT8zu9o7vfjgGp6X3/8x9n76qIqClda2a5Lti60MHkP5bWQ7XIornZ8lEbRa/lfZs6kukKqylNa
UYWzrKiNRkesOon69Rb3e8kWM29lz2G+t+uboPpPoexY1V/I6rqd7DSzQvLXtK61Ffw+dr9nLor8
DXXr+D3nn+zfckWIP+3u7uZ6etJ/Vm9YJfYe/D6nQqb/jH9NXudrY7asNbUx94h1fqxdr0X8Xlo1
Wb2WnHnLO4zaT6H6WMXy19btscczn1Lh35vTp8jvWIbf89H07NXSyO+Jlcqvz/zqM3896jje35t1
YdV+sv+ePWK/fq+qkOoehzq/19fGvI9gruKraqFN/0yuqNm1F+0ZmbN+7adQvW1pPVfXbf4o+dse
guf38fs931tQFy6VdlPkHFPWyV8lvLN7k76Jkk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bLd95WIvPa/pmb
076Y3V1+B79jk7nvwYu9+31v/6Wbs+OUWau1lt3Vh0/36/c3v3sye48x7Tc/fDUt5pHOS/S/s1PW
PzPtgeF38DtGS2YwMuO0WdmVrbEWpgOkhdLt7SdN1cwEz3TENNtzszMrfX4HvwMA+B0A+B0AwO8A
AH4HAPA7AIDfAQD8DgD8DgDgdwAAvwMA+B0AwO8AAH4HAH4HAPA7AGCD/P7iiy++AAAYF+H2/wfV
NRpJA0xVBAAAAABJRU5ErkJggg==
--0000000000009dc518057fca2a17--
.
Author: joel.g.hemphill@gmail.com
Date: Tue, 22 Jan 2019 09:50:59 -0800 (PST)
Raw View
------=_Part_2623_87763843.1548179459654
Content-Type: multipart/alternative;
boundary="----=_Part_2624_565982781.1548179459655"
------=_Part_2624_565982781.1548179459655
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I wasn't aware of Google Benchmark before now. I will attempt to=20
familiarize myself with it, so that I can get more accurate timings. In the=
=20
meanwhile, below is my implementation of what I hope to propose. If the=20
results from Google Benchmark don't align with what I have presented, I=20
sincerely apologize for the misinformation.
__declspec(naked) __int32 __fastcall powi(__int32 base, __int32 exponent) {
__asm {
// No Stack Usage
/*------- Prolog ---------*/
//push ebp
//mov ebp, esp
//sub esp, __LOCAL_SIZE
/*------------------------*/
// Entry Register Values
//------------------------
// EAX =3D UNDEFINED
// EBX =3D UNDEFINED
// ECX =3D base
// EDX =3D exponent
// ESI =3D UNDEFINED
// EDI =3D UNDEFINED
//------------------------
// eax =3D 0
xor eax, eax;
// if(exponent =3D=3D 0) { return 1; }
test edx, edx;
jnz if_zero_exp;
inc eax; // Set eax to 1
jmp powi_exit;
if_zero_exp:
=20
// if(base =3D=3D 0) { return 0; }
test ecx, ecx;
jz powi_exit;
// ebx =3D base
// ecx =3D exponent
mov ebx, ecx;
mov ecx, edx;
=20
// ecx =3D abs(exponent)
// edx =3D sign(exponent)
sar edx, 31;
xor ecx, edx;
sub ecx, edx;
// Create a copy of the base, and move it to a temporary register
mov esi, ebx;
=20
/* find abs(base) */
mov eax, ebx; // Copy the base to the accumulator
sar eax, 31; // Fill with sign bit
xor ebx, eax; // Not the value, if sign bit is set
sub ebx, eax; // Subtract the sign bit, giving the absolute value
=20
// Return the copy to the accumulator
mov eax, esi;
// EAX =3D base
// EBX =3D abs(base)
// ECX =3D abs(exponent)
// EDX =3D sign(exponent)
// if exponent is negative
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
test edx, edx;
jz if_exp_sign_eq_0;
// if abs(base) =3D=3D 1
/*----------------------------*/
cmp ebx, 1;
jg if_base_gt_1;
// ecx =3D exponent & 1
and ecx, ebx;
=20
// eax =3D exponent & 1 ? (base < 0 ? -1 : 1) : 0
imul ecx;
// ecx =3D exponent & 1 ? 0 : 1
xor ecx, ebx;
// eax =3D exponent & 1 ? (base < 0 ? -1 : 1) : 1
add eax, ecx;
// Return exponent & 1 ? (base < 0 ? -1 : 1) : 1
jmp powi_exit;
if_base_gt_1:
/*----------------------------*/
=20
// Return 0
xor eax, eax;
jmp powi_exit;
if_exp_sign_eq_0:
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/* if exponent =3D=3D 1, return base */
dec ecx;
jz powi_exit;
// If base =3D=3D 2
//cmp ebx, 2;
//jne if_base_2;
// sal eax, cl;
// ret;
//if_base_2:
/* Exponentiate the multiplication */
mov ebx, eax;
multiply:
shr ecx, 1; // Shift and check the first bit of the loop counter
jnc noMulByEBX
imul ebx; // Multiply by the current multiplier
noMulByEBX:
imul ebx, ebx; // Square the multiplier
test ecx, ecx; // Test if this was the last itteration
jnz multiply;
/* Exit the function, returning the value of eax */
powi_exit :
// No stack usage
/*------- Epilog ---------*/
//mov esp, ebp;
//pop ebp;
/*------------------------*/
ret;
}
}
On Friday, January 18, 2019 at 10:59:21 PM UTC-8, Arthur O'Dwyer wrote:
>
> On Fri, Jan 18, 2019 at 8:12 PM <joel.g....@gmail.com <javascript:>>=20
> wrote:
>
>> The case you pointed out of using the double-type of the return for=20
>> 'pow(int, int)' would be a major concern. Perhaps a workaround would be =
the=20
>> requirement of an explicit template? i.e. "double x =3D std::pow(10, 20)=
;"=20
>> would use overload 7, whereas "std::pow<int, int>(10, 20)" would return=
=20
>> int? Alternatively, as Jake Arkinstall suggested, a new syntax for 'pow'=
as=20
>> 'power' might be in order, in which case, such contingencies wouldn't be=
as=20
>> large a concern. I would also argue that the above code segment is poor=
=20
>> practice, as it is relying upon the pow function to convert the two=20
>> integers to doubles. More explicit typing would be preferred in most cod=
ing=20
>> environments. Another solution, as is implemented with powl and powf, is=
to=20
>> use a single-letter abbreviation to explicitly define the types used. i.=
e.=20
>> powi.
>>
>> As for the graph; I mentioned in a reply to my original posting that I=
=20
>> have since found an issue with the testing method I used for graphing th=
e=20
>> execution times for pow and powi. I have since done other tests as shown=
=20
>> below [avg. of 20000 runs for powi, and 500 for pow (since the execution=
is=20
>> longer, I decided to neglect the sample-count somewhat)]:
>>
>> [image: Untitled2.png]
>>
>> As you can see, powi does experience a gradual increase in execution=20
>> length with the increasing exponents (since it needs to do at worst [if =
an=20
>> implementation were to use a simple linear approach, O(n) multiplication=
s]).
>>
> But really O(lg n) multiplications, right?
> That graph looks a lot better (flatter), but I'd still have to see the=20
> code before I believe it. You say your data was
>
> > gathered using "std::chrono::high_resolution_clock::now()" surrounding=
=20
> for-loops executing the functions
>
> which pointedly omits any reference to e.g. Google Benchmark=20
> <https://github.com/google/benchmark> or ClobberMemory/DoNotOptimize.=20
> Which suggests that your benchmark might not have been measuring anything=
=20
> meaningful.
>
> =E2=80=93Arthur
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/7801bc16-e087-43ed-ab4f-5b5f907c125f%40isocpp.or=
g.
------=_Part_2624_565982781.1548179459655
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I wasn't aware of Google Benchmark before now. I will =
attempt to familiarize myself with it, so that I can get more accurate timi=
ngs. In the meanwhile, below is my implementation of what I hope to propose=
.. If the results from Google Benchmark don't align with what I have pre=
sented, I sincerely apologize for the misinformation.<div><br></div><div><d=
iv class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bor=
der-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; over=
flow-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpretty=
print"><span style=3D"color: #000;" class=3D"styled-by-prettify">__declspec=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">naked</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> __int32 __fastcall powi</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">__int32 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">base</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> __int32 exponent</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 __asm </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// No Stack Usage</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">/*------- Prolog ---------*/</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//push ebp</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">//mov ebp, esp</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">//sub esp, __LOCAL_SIZE</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">/*---------------=
---------*/</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">// Entry Register Values</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">//------------------------</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// EAX =3D UNDEFINED</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">// EBX =3D UNDEFINED</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ECX =3D =
base</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
EDX =3D exponent</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// ESI =3D UNDEFINED</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// EDI =3D UNDEFINED</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">//------------------------</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 </span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// eax =3D 0</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 xor ea=
x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> eax</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 </span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">// if(exponent =3D=3D 0)=
{ return 1; }</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 test edx</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> edx</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
jnz if_zero_exp</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 inc eax</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// Set eax to =
1</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 jmp powi_exit</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>if_zero_exp</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0<br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// if(base =3D=3D 0) { return 0; }</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 test ecx</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> ecx</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 jz powi_exit</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// ebx =3D base</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">// ecx =3D exponent</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 mov ebx</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> ecx</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>=C2=A0 mov ecx</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> edx</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br><br>=C2=A0<br>=C2=A0 </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// ecx =3D abs(exponent)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">// edx =3D sign(exponent)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 s=
ar edx</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #066;" class=3D"styled-by-prettify">31</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 xor ecx</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> edx</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">sub</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> ecx</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> edx</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
Create a copy of the base, and move it to a temporary register</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 mov esi</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> ebx</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0<br>=C2=A0 </span><span sty=
le=3D"color: #800;" class=3D"styled-by-prettify">/* find abs(base) */</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 mov e=
ax</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> ebx</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">// Copy the base to the accumulator</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 sar e=
ax</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">31</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// Fill with sign bit</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 xor ebx</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> eax</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// Not the value, if sign bit is set</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">sub</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> ebx</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> eax</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// S=
ubtract the sign bit, giving the absolute value</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br>=C2=A0<br>=C2=A0 </span><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">// Return the copy to the a=
ccumulator</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 mov eax</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
esi</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// EAX=
=3D base</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
// EBX =3D abs(base)</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// ECX =3D abs(exponent)</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">// EDX =3D sign(exponent)</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 </span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">// if exponent is negativ=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D*/</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 test edx</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> edx</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 jz if_exp_sign_eq_0</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">// if abs(base) =3D=3D 1</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">/*----------------------------*/</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 cmp ebx</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 jg if_base_gt_1</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">// ecx =3D exponent & 1</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">and</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> ecx</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> ebx</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0<br>=C2=A0 </span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">// eax =3D exponent & 1 ? (base < 0 ? -1 :=
1) : 0</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>=C2=A0 imul ecx</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">// ecx =3D exponent & 1 ? 0 : 1</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 xor ecx</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> ebx</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// eax =3D exponent & 1 ? (base < 0 ? -1 : 1=
) : 1</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 add eax</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ecx<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Return e=
xponent & 1 ? (base < 0 ? -1 : 1) : 1</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 jmp powi_exit</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>if_base_gt_1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">/*----------------------------*/</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0<br>=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
Return 0</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 xor eax</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ea=
x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 jmp pow=
i_exit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>i=
f_exp_sign_eq_0</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D*/</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">/* if exponent =3D=3D 1, return base */</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 dec ecx</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 jz powi_exit=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=C2=A0 =
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// If base=
=3D=3D 2</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
//cmp ebx, 2;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//jne if_base_2;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// sal eax, cl;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">// ret;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//if_base_2:</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">/* Exponentiate the multiplication */</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 mov ebx</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> eax</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>multiply</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 shr ecx</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D=
"styled-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> =C2=A0 =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// Shift and check the first bit of the loop counter</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 jnc noMulByEBX<=
br>=C2=A0 imul ebx</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
=C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// M=
ultiply by the current multiplier</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>noMulByEBX</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 imul ebx</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> ebx</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Sq=
uare the multiplier</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 test ecx</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> ecx</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// Test if this=
was the last itteration</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br>=C2=A0 jnz multiply</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">/* Exit the function, returning the value of eax=
*/</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>pow=
i_exit </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// No stack=
usage</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*-=
------ Epilog ---------*/</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">//mov esp, ebp;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//pop ebp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">/*------------------------*/</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 ret</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span></div></code></div><br><br>On Friday, January 18,=
2019 at 10:59:21 PM UTC-8, Arthur O'Dwyer wrote:<blockquote class=3D"g=
mail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc sol=
id;padding-left: 1ex;"><div dir=3D"ltr"><div dir=3D"ltr">On Fri, Jan 18, 20=
19 at 8:12 PM <<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"MmOfQxNrFAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'ja=
vascript:';return true;" onclick=3D"this.href=3D'javascript:';r=
eturn true;">joel.g....@gmail.com</a>> wrote:<br></div><div class=3D"gma=
il_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,=
204,204);padding-left:1ex"><div dir=3D"ltr">The case you pointed out of usi=
ng the double-type of the return for 'pow(int, int)' would be a maj=
or concern. Perhaps a workaround would be the requirement of an explicit te=
mplate? i.e. "double x =3D std::pow(10, 20);" would use overload =
7, whereas "std::pow<int, int>(10, 20)" would return int? A=
lternatively, as Jake Arkinstall suggested, a new syntax for 'pow' =
as 'power' might be in order, in which case, such contingencies wou=
ldn't be as large a concern. I would also argue that the above code seg=
ment is poor practice, as it is relying upon the pow function to convert th=
e two integers to doubles. More explicit typing would be preferred in most =
coding environments. Another solution, as is implemented with powl and powf=
, is to use a single-letter abbreviation to explicitly define the types use=
d. i.e. powi.<div><br></div><div>As for the graph; I mentioned in a reply t=
o my original posting that I have since found an issue with the testing met=
hod I used for graphing the execution times for pow and powi. I have since =
done other tests as shown below [avg. of 20000 runs for powi, and 500 for p=
ow (since the execution is longer, I decided to neglect the sample-count so=
mewhat)]:</div><div><br></div><p style=3D"text-align:left;clear:both"><img =
src=3D"https://groups.google.com/a/isocpp.org/group/std-proposals/attach/14=
6b13439f6332/Untitled2.png?part=3D0.1&view=3D1&authuser=3D2" alt=3D=
"Untitled2.png" width=3D"320" height=3D"183" style=3D"margin-left:1em;margi=
n-right:1em"></p><p style=3D"text-align:left;clear:both">As you can see, po=
wi does experience a gradual increase in execution length with the increasi=
ng exponents (since it needs to do at worst [if an implementation were to u=
se a simple linear approach, O(n) multiplications]).<br></p></div></blockqu=
ote><div>But really O(lg n) multiplications, right?</div><div>That graph lo=
oks a lot better (flatter), but I'd still have to see the code before I=
believe it. You say your data was</div><div><br></div><div>> gathered u=
sing "std::chrono::high_resolution_<wbr>clock::now()" surrounding=
for-loops executing the functions</div><div><br></div><div>which pointedly=
omits any reference to e.g. <a href=3D"https://github.com/google/benchmark=
" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https:=
//www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fgoogle%2Fbenchmark\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEpR8YTYO6UOopr4cXneXU3k6mEaA';retu=
rn true;" onclick=3D"this.href=3D'https://www.google.com/url?q\x3dhttps=
%3A%2F%2Fgithub.com%2Fgoogle%2Fbenchmark\x26sa\x3dD\x26sntz\x3d1\x26usg\x3d=
AFQjCNEpR8YTYO6UOopr4cXneXU3k6mEaA';return true;">Google Benchmark</a> =
or ClobberMemory/DoNotOptimize. Which suggests that your benchmark might no=
t have been measuring anything meaningful.</div><div><br></div><div>=E2=80=
=93Arthur</div></div></div>
</blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7801bc16-e087-43ed-ab4f-5b5f907c125f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7801bc16-e087-43ed-ab4f-5b5f907c125f=
%40isocpp.org</a>.<br />
------=_Part_2624_565982781.1548179459655--
------=_Part_2623_87763843.1548179459654--
.
Author: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Date: Tue, 22 Jan 2019 12:52:39 -0500
Raw View
--000000000000d94f3f05800fa4c0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Why don't you just post your benchmark code? Why all the graphs and "oops
here's the new graph" and so on?
On Tue, Jan 22, 2019 at 12:51 PM <joel.g.hemphill@gmail.com> wrote:
> I wasn't aware of Google Benchmark before now. I will attempt to
> familiarize myself with it, so that I can get more accurate timings. In t=
he
> meanwhile, below is my implementation of what I hope to propose. If the
> results from Google Benchmark don't align with what I have presented, I
> sincerely apologize for the misinformation.
>
> __declspec(naked) __int32 __fastcall powi(__int32 base, __int32 exponent)
> {
> __asm {
> // No Stack Usage
> /*------- Prolog ---------*/
> //push ebp
> //mov ebp, esp
> //sub esp, __LOCAL_SIZE
> /*------------------------*/
>
>
> // Entry Register Values
> //------------------------
> // EAX =3D UNDEFINED
> // EBX =3D UNDEFINED
> // ECX =3D base
> // EDX =3D exponent
> // ESI =3D UNDEFINED
> // EDI =3D UNDEFINED
> //------------------------
>
>
> // eax =3D 0
> xor eax, eax;
>
>
> // if(exponent =3D=3D 0) { return 1; }
> test edx, edx;
> jnz if_zero_exp;
> inc eax; // Set eax to 1
> jmp powi_exit;
> if_zero_exp:
>
> // if(base =3D=3D 0) { return 0; }
> test ecx, ecx;
> jz powi_exit;
>
>
> // ebx =3D base
> // ecx =3D exponent
> mov ebx, ecx;
> mov ecx, edx;
>
>
>
> // ecx =3D abs(exponent)
> // edx =3D sign(exponent)
> sar edx, 31;
> xor ecx, edx;
> sub ecx, edx;
>
>
> // Create a copy of the base, and move it to a temporary register
> mov esi, ebx;
>
> /* find abs(base) */
> mov eax, ebx; // Copy the base to the accumulator
> sar eax, 31; // Fill with sign bit
> xor ebx, eax; // Not the value, if sign bit is set
> sub ebx, eax; // Subtract the sign bit, giving the absolute value
>
> // Return the copy to the accumulator
> mov eax, esi;
>
>
> // EAX =3D base
> // EBX =3D abs(base)
> // ECX =3D abs(exponent)
> // EDX =3D sign(exponent)
>
>
> // if exponent is negative
> /*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
> test edx, edx;
> jz if_exp_sign_eq_0;
>
>
> // if abs(base) =3D=3D 1
> /*----------------------------*/
> cmp ebx, 1;
> jg if_base_gt_1;
> // ecx =3D exponent & 1
> and ecx, ebx;
>
> // eax =3D exponent & 1 ? (base < 0 ? -1 : 1) : 0
> imul ecx;
>
>
> // ecx =3D exponent & 1 ? 0 : 1
> xor ecx, ebx;
>
>
> // eax =3D exponent & 1 ? (base < 0 ? -1 : 1) : 1
> add eax, ecx;
>
>
> // Return exponent & 1 ? (base < 0 ? -1 : 1) : 1
> jmp powi_exit;
> if_base_gt_1:
> /*----------------------------*/
>
> // Return 0
> xor eax, eax;
> jmp powi_exit;
>
>
> if_exp_sign_eq_0:
> /*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
>
>
> /* if exponent =3D=3D 1, return base */
> dec ecx;
> jz powi_exit;
>
>
> // If base =3D=3D 2
> //cmp ebx, 2;
> //jne if_base_2;
> // sal eax, cl;
> // ret;
> //if_base_2:
>
>
> /* Exponentiate the multiplication */
> mov ebx, eax;
> multiply:
> shr ecx, 1; // Shift and check the first bit of the loop counter
> jnc noMulByEBX
> imul ebx; // Multiply by the current multiplier
> noMulByEBX:
> imul ebx, ebx; // Square the multiplier
> test ecx, ecx; // Test if this was the last itteration
> jnz multiply;
>
>
> /* Exit the function, returning the value of eax */
> powi_exit :
> // No stack usage
> /*------- Epilog ---------*/
> //mov esp, ebp;
> //pop ebp;
> /*------------------------*/
> ret;
> }
> }
>
>
> On Friday, January 18, 2019 at 10:59:21 PM UTC-8, Arthur O'Dwyer wrote:
>>
>> On Fri, Jan 18, 2019 at 8:12 PM <joel.g....@gmail.com> wrote:
>>
>>> The case you pointed out of using the double-type of the return for
>>> 'pow(int, int)' would be a major concern. Perhaps a workaround would be=
the
>>> requirement of an explicit template? i.e. "double x =3D std::pow(10, 20=
);"
>>> would use overload 7, whereas "std::pow<int, int>(10, 20)" would return
>>> int? Alternatively, as Jake Arkinstall suggested, a new syntax for 'pow=
' as
>>> 'power' might be in order, in which case, such contingencies wouldn't b=
e as
>>> large a concern. I would also argue that the above code segment is poor
>>> practice, as it is relying upon the pow function to convert the two
>>> integers to doubles. More explicit typing would be preferred in most co=
ding
>>> environments. Another solution, as is implemented with powl and powf, i=
s to
>>> use a single-letter abbreviation to explicitly define the types used. i=
..e.
>>> powi.
>>>
>>> As for the graph; I mentioned in a reply to my original posting that I
>>> have since found an issue with the testing method I used for graphing t=
he
>>> execution times for pow and powi. I have since done other tests as show=
n
>>> below [avg. of 20000 runs for powi, and 500 for pow (since the executio=
n is
>>> longer, I decided to neglect the sample-count somewhat)]:
>>>
>>> [image: Untitled2.png]
>>>
>>> As you can see, powi does experience a gradual increase in execution
>>> length with the increasing exponents (since it needs to do at worst [if=
an
>>> implementation were to use a simple linear approach, O(n) multiplicatio=
ns]).
>>>
>> But really O(lg n) multiplications, right?
>> That graph looks a lot better (flatter), but I'd still have to see the
>> code before I believe it. You say your data was
>>
>> > gathered using "std::chrono::high_resolution_clock::now()" surrounding
>> for-loops executing the functions
>>
>> which pointedly omits any reference to e.g. Google Benchmark
>> <https://github.com/google/benchmark> or ClobberMemory/DoNotOptimize.
>> Which suggests that your benchmark might not have been measuring anythin=
g
>> meaningful.
>>
>> =E2=80=93Arthur
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/y9qMRNKrS2E/=
unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7801bc16-e08=
7-43ed-ab4f-5b5f907c125f%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7801bc16-e0=
87-43ed-ab4f-5b5f907c125f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CADvuK0%2B1ZC60c%2B9ScSKNtu2id34E6wVnXzQ7WP61cKh=
u%2BeYARg%40mail.gmail.com.
--000000000000d94f3f05800fa4c0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Why don't you just post your benchmark code? Why all t=
he graphs and "oops here's the new graph" and so on?</div><br=
><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, J=
an 22, 2019 at 12:51 PM <<a href=3D"mailto:joel.g.hemphill@gmail.com">jo=
el.g.hemphill@gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_=
quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-=
style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr">I wasn't aware of Google Benchmark before now. I will attempt =
to familiarize myself with it, so that I can get more accurate timings. In =
the meanwhile, below is my implementation of what I hope to propose. If the=
results from Google Benchmark don't align with what I have presented, =
I sincerely apologize for the misinformation.<div><br></div><div><div class=
=3D"gmail-m_-1637743423785989120prettyprint" style=3D"background-color:rgb(=
250,250,250);border:1px solid rgb(187,187,187)"><code class=3D"gmail-m_-163=
7743423785989120prettyprint"><div class=3D"gmail-m_-1637743423785989120subp=
rettyprint"><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774342378=
5989120styled-by-prettify">__declspec</span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">(</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by=
-prettify">naked</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
m_-1637743423785989120styled-by-prettify">)</span><span style=3D"color:rgb(=
0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> __int32 _=
_fastcall powi</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_=
-1637743423785989120styled-by-prettify">(</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">__int32 </sp=
an><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_-1637743423785989120=
styled-by-prettify">base</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
__int32 exponent</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail=
-m_-1637743423785989120styled-by-prettify">)</span><span style=3D"color:rgb=
(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> </span><=
span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120st=
yled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify"><br>=C2=A0 __asm </span><span styl=
e=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-p=
rettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743=
423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(=
136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// No St=
ack Usage</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(1=
36,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">/*-------=
Prolog ---------*/</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"c=
olor:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"=
>//push ebp</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774=
3423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb=
(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">//mov e=
bp, esp</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423=
785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136=
,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">//sub esp, =
__LOCAL_SIZE</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rg=
b(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">/*----=
--------------------*/</span><span style=3D"color:rgb(0,0,0)" class=3D"gmai=
l-m_-1637743423785989120styled-by-prettify"><br><br><br>=C2=A0 </span><span=
style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-b=
y-prettify">// Entry Register Values</span><span style=3D"color:rgb(0,0,0)"=
class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 </span=
><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120st=
yled-by-prettify">//------------------------</span><span style=3D"color:rgb=
(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377434237=
85989120styled-by-prettify">// EAX =3D UNDEFINED</span><span style=3D"color=
:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify">// EBX =3D UNDEFINED</span><span style=3D"co=
lor:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><b=
r>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-163774=
3423785989120styled-by-prettify">// ECX =3D base</span><span style=3D"color=
:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify">// EDX =3D exponent</span><span style=3D"col=
or:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br=
>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743=
423785989120styled-by-prettify">// ESI =3D UNDEFINED</span><span style=3D"c=
olor:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><=
br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify">// EDI =3D UNDEFINED</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"=
><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-163=
7743423785989120styled-by-prettify">//------------------------</span><span =
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-p=
rettify"><br><br><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify">// eax =3D 0</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by=
-prettify"><br>=C2=A0 xor eax</span><span style=3D"color:rgb(102,102,0)" cl=
ass=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pretti=
fy"> eax</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br><br><br>=C2=A0=
</span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377434237859=
89120styled-by-prettify">// if(exponent =3D=3D 0) { return 1; }</span><span=
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-=
prettify"><br>=C2=A0 test edx</span><span style=3D"color:rgb(102,102,0)" cl=
ass=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pretti=
fy"> edx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 jnz if_=
zero_exp</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 inc eax=
</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785=
989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_-1637743423785989120styled-by-prettify"> </span><span style=3D"col=
or:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">/=
/ Set eax to 1</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163=
7743423785989120styled-by-prettify"><br>=C2=A0 jmp powi_exit</span><span st=
yle=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by=
-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify"><br>if_zero_exp</span><span style=3D"colo=
r:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
:</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989=
120styled-by-prettify"><br>=C2=A0<br>=C2=A0 </span><span style=3D"color:rgb=
(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// if(b=
ase =3D=3D 0) { return 0; }</span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 test ecx</span>=
<span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120s=
tyled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_-1637743423785989120styled-by-prettify"> ecx</span><span style=3D"color:r=
gb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">;</=
span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120=
styled-by-prettify"><br>=C2=A0 jz powi_exit</span><span style=3D"color:rgb(=
102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">;</spa=
n><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120sty=
led-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0=
)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// ebx =3D base=
</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377434237859891=
20styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" =
class=3D"gmail-m_-1637743423785989120styled-by-prettify">// ecx =3D exponen=
t</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989=
120styled-by-prettify"><br>=C2=A0 mov ebx</span><span style=3D"color:rgb(10=
2,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120style=
d-by-prettify"> ecx</span><span style=3D"color:rgb(102,102,0)" class=3D"gma=
il-m_-1637743423785989120styled-by-prettify">;</span><span style=3D"color:r=
gb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=
=A0 mov ecx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16=
37743423785989120styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> edx</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120style=
d-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1=
637743423785989120styled-by-prettify"><br><br><br>=C2=A0<br>=C2=A0 </span><=
span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styl=
ed-by-prettify">// ecx =3D abs(exponent)</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 </=
span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377434237859891=
20styled-by-prettify">// edx =3D sign(exponent)</span><span style=3D"color:=
rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=
=C2=A0 sar edx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_=
-1637743423785989120styled-by-prettify">,</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> </span><spa=
n style=3D"color:rgb(0,102,102)" class=3D"gmail-m_-1637743423785989120style=
d-by-prettify">31</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail=
-m_-1637743423785989120styled-by-prettify">;</span><span style=3D"color:rgb=
(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=
=A0 xor ecx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16=
37743423785989120styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> edx</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120style=
d-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1=
637743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"colo=
r:rgb(0,0,136)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">su=
b</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989=
120styled-by-prettify"> ecx</span><span style=3D"color:rgb(102,102,0)" clas=
s=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"=
> edx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-m_-1637743423785989120styled-by-prettify"><br><br><br>=C2=A0 </=
span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377434237859891=
20styled-by-prettify">// Create a copy of the base, and move it to a tempor=
ary register</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify"><br>=C2=A0 mov esi</span><span style=3D"c=
olor:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettif=
y">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785=
989120styled-by-prettify"> ebx</span><span style=3D"color:rgb(102,102,0)" c=
lass=3D"gmail-m_-1637743423785989120styled-by-prettify">;</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pretti=
fy"><br>=C2=A0<br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D=
"gmail-m_-1637743423785989120styled-by-prettify">/* find abs(base) */</span=
><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styl=
ed-by-prettify"><br>=C2=A0 mov eax</span><span style=3D"color:rgb(102,102,0=
)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><span s=
tyle=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pr=
ettify"> ebx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1=
637743423785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,=
0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> </span><span =
style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by=
-prettify">// Copy the base to the accumulator</span><span style=3D"color:r=
gb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=
=A0 sar eax</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16=
37743423785989120styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> </span><span s=
tyle=3D"color:rgb(0,102,102)" class=3D"gmail-m_-1637743423785989120styled-b=
y-prettify">31</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_=
-1637743423785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> =C2=A0</spa=
n><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120s=
tyled-by-prettify">// Fill with sign bit</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 xo=
r ebx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-m_-1637743423785989120styled-by-prettify"> eax</span><span styl=
e=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-p=
rettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743=
423785989120styled-by-prettify"> </span><span style=3D"color:rgb(136,0,0)" =
class=3D"gmail-m_-1637743423785989120styled-by-prettify">// Not the value, =
if sign bit is set</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_=
-1637743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"co=
lor:rgb(0,0,136)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
sub</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377434237859=
89120styled-by-prettify"> ebx</span><span style=3D"color:rgb(102,102,0)" cl=
ass=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pretti=
fy"> eax</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_-1637743423785989120styled-by-prettify"> </span><span styl=
e=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pre=
ttify">// Subtract the sign bit, giving the absolute value</span><span styl=
e=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prett=
ify"><br>=C2=A0<br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify">// Return the copy to t=
he accumulator</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163=
7743423785989120styled-by-prettify"><br>=C2=A0 mov eax</span><span style=3D=
"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prett=
ify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377434237=
85989120styled-by-prettify"> esi</span><span style=3D"color:rgb(102,102,0)"=
class=3D"gmail-m_-1637743423785989120styled-by-prettify">;</span><span sty=
le=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pret=
tify"><br><br><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D=
"gmail-m_-1637743423785989120styled-by-prettify">// EAX =3D base</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by=
-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gm=
ail-m_-1637743423785989120styled-by-prettify">// EBX =3D abs(base)</span><s=
pan style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-=
by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"=
gmail-m_-1637743423785989120styled-by-prettify">// ECX =3D abs(exponent)</s=
pan><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120s=
tyled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" cla=
ss=3D"gmail-m_-1637743423785989120styled-by-prettify">// EDX =3D sign(expon=
ent)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785=
989120styled-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color:rg=
b(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// if =
exponent is negative</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_-1637743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"=
color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify=
">/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D*/</span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 test edx</sp=
an><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377434237859891=
20styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gma=
il-m_-1637743423785989120styled-by-prettify"> edx</span><span style=3D"colo=
r:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989=
120styled-by-prettify"><br>=C2=A0 jz if_exp_sign_eq_0</span><span style=3D"=
color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-pretti=
fy">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774342378=
5989120styled-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color:r=
gb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// if=
abs(base) =3D=3D 1</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"c=
olor:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"=
>/*----------------------------*/</span><span style=3D"color:rgb(0,0,0)" cl=
ass=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 cmp ebx</=
span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-163774342378598=
9120styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"g=
mail-m_-1637743423785989120styled-by-prettify"> </span><span style=3D"color=
:rgb(0,102,102)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">1=
</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785=
989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 jg if_base_gt_1=
</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785=
989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 </span><span st=
yle=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-p=
rettify">// ecx =3D exponent & 1</span><span style=3D"color:rgb(0,0,0)"=
class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 </span=
><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_-1637743423785989120st=
yled-by-prettify">and</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail=
-m_-1637743423785989120styled-by-prettify"> ecx</span><span style=3D"color:=
rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">,<=
/span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774342378598912=
0styled-by-prettify"> ebx</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify">;</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
<br>=C2=A0<br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gma=
il-m_-1637743423785989120styled-by-prettify">// eax =3D exponent & 1 ? =
(base < 0 ? -1 : 1) : 0</span><span style=3D"color:rgb(0,0,0)" class=3D"=
gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 imul ecx</span><=
span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120st=
yled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify"><br><br><br>=C2=A0 </span><span st=
yle=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-p=
rettify">// ecx =3D exponent & 1 ? 0 : 1</span><span style=3D"color:rgb=
(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=
=A0 xor ecx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16=
37743423785989120styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> ebx</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120style=
d-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1=
637743423785989120styled-by-prettify"><br><br><br>=C2=A0 </span><span style=
=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pret=
tify">// eax =3D exponent & 1 ? (base < 0 ? -1 : 1) : 1</span><span =
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-p=
rettify"><br>=C2=A0 add eax</span><span style=3D"color:rgb(102,102,0)" clas=
s=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"=
> ecx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-m_-1637743423785989120styled-by-prettify"><br><br><br>=C2=A0 </=
span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-16377434237859891=
20styled-by-prettify">// Return exponent & 1 ? (base < 0 ? -1 : 1) :=
1</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774342378598=
9120styled-by-prettify"><br>=C2=A0 jmp powi_exit</span><span style=3D"color=
:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">;=
</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377434237859891=
20styled-by-prettify"><br>if_base_gt_1</span><span style=3D"color:rgb(102,1=
02,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">:</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-b=
y-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"g=
mail-m_-1637743423785989120styled-by-prettify">/*--------------------------=
--*/</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785=
989120styled-by-prettify"><br>=C2=A0<br>=C2=A0 </span><span style=3D"color:=
rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// R=
eturn 0</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423=
785989120styled-by-prettify"><br>=C2=A0 xor eax</span><span style=3D"color:=
rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">,<=
/span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774342378598912=
0styled-by-prettify"> eax</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify">;</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
<br>=C2=A0 jmp powi_exit</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify">;</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
<br><br><br>if_exp_sign_eq_0</span><span style=3D"color:rgb(102,102,0)" cla=
ss=3D"gmail-m_-1637743423785989120styled-by-prettify">:</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-pretti=
fy"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-=
1637743423785989120styled-by-prettify">/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-b=
y-prettify"><br><br><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" cl=
ass=3D"gmail-m_-1637743423785989120styled-by-prettify">/* if exponent =3D=
=3D 1, return base */</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail=
-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 dec ecx</span><span s=
tyle=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-b=
y-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637=
743423785989120styled-by-prettify"><br>=C2=A0 jz powi_exit</span><span styl=
e=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-p=
rettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743=
423785989120styled-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"co=
lor:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
// If base =3D=3D 2</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"c=
olor:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"=
>//cmp ebx, 2;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163=
7743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:=
rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">//jn=
e if_base_2;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377=
43423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rg=
b(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// sal=
eax, cl;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(1=
36,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// ret;</=
span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120=
styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" cl=
ass=3D"gmail-m_-1637743423785989120styled-by-prettify">//if_base_2:</span><=
span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled=
-by-prettify"><br><br><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" =
class=3D"gmail-m_-1637743423785989120styled-by-prettify">/* Exponentiate th=
e multiplication */</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify"><br>=C2=A0 mov ebx</span><span sty=
le=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-=
prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774=
3423785989120styled-by-prettify"> eax</span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">;</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by=
-prettify"><br>multiply</span><span style=3D"color:rgb(102,102,0)" class=3D=
"gmail-m_-1637743423785989120styled-by-prettify">:</span><span style=3D"col=
or:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br=
>=C2=A0 shr ecx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify">,</span><span style=3D"color:rgb(0=
,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> </span><sp=
an style=3D"color:rgb(0,102,102)" class=3D"gmail-m_-1637743423785989120styl=
ed-by-prettify">1</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail=
-m_-1637743423785989120styled-by-prettify">;</span><span style=3D"color:rgb=
(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> =C2=A0 =
=C2=A0</span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-163774342=
3785989120styled-by-prettify">// Shift and check the first bit of the loop =
counter</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423=
785989120styled-by-prettify"><br>=C2=A0 jnc noMulByEBX<br>=C2=A0 imul ebx</=
span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-163774342378598=
9120styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=3D"g=
mail-m_-1637743423785989120styled-by-prettify"> =C2=A0</span><span style=3D=
"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettif=
y">// Multiply by the current multiplier</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>noMulByEB=
X</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-163774342378=
5989120styled-by-prettify">:</span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify"><br>=C2=A0 imul ebx</sp=
an><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-16377434237859891=
20styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gma=
il-m_-1637743423785989120styled-by-prettify"> ebx</span><span style=3D"colo=
r:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989=
120styled-by-prettify"> </span><span style=3D"color:rgb(136,0,0)" class=3D"=
gmail-m_-1637743423785989120styled-by-prettify">// Square the multiplier</s=
pan><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120s=
tyled-by-prettify"><br>=C2=A0 test ecx</span><span style=3D"color:rgb(102,1=
02,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">,</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-b=
y-prettify"> ecx</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
m_-1637743423785989120styled-by-prettify">;</span><span style=3D"color:rgb(=
0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"> </span><s=
pan style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120style=
d-by-prettify">// Test if this was the last itteration</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"=
><br>=C2=A0 jnz multiply</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-1637743423785989120styled-by-prettify">;</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
<br><br><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D"gmail=
-m_-1637743423785989120styled-by-prettify">/* Exit the function, returning =
the value of eax */</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-1637743423785989120styled-by-prettify"><br>powi_exit </span><span style=
=3D"color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-pr=
ettify">:</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16377434=
23785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(1=
36,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">// No sta=
ck usage</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774342=
3785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(13=
6,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">/*------- =
Epilog ---------*/</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_=
-1637743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"co=
lor:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">=
//mov esp, ebp;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-16=
37743423785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color=
:rgb(136,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">//p=
op ebp;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423=
785989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(136=
,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">/*---------=
---------------*/</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-=
1637743423785989120styled-by-prettify"><br>=C2=A0 ret</span><span style=3D"=
color:rgb(102,102,0)" class=3D"gmail-m_-1637743423785989120styled-by-pretti=
fy">;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-163774342378=
5989120styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:rgb(102,1=
02,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify">}</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-1637743423785989120styled-b=
y-prettify"><br></span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
m_-1637743423785989120styled-by-prettify">}</span><span style=3D"color:rgb(=
0,0,0)" class=3D"gmail-m_-1637743423785989120styled-by-prettify"><br></span=
></div></code></div><br><br>On Friday, January 18, 2019 at 10:59:21 PM UTC-=
8, Arthur O'Dwyer wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-l=
eft-color:rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div dir=3D"l=
tr">On Fri, Jan 18, 2019 at 8:12 PM <<a rel=3D"nofollow">joel.g....@gmai=
l.com</a>> wrote:<br></div><div class=3D"gmail_quote"><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">=
<div dir=3D"ltr">The case you pointed out of using the double-type of the r=
eturn for 'pow(int, int)' would be a major concern. Perhaps a worka=
round would be the requirement of an explicit template? i.e. "double x=
=3D std::pow(10, 20);" would use overload 7, whereas "std::pow&l=
t;int, int>(10, 20)" would return int? Alternatively, as Jake Arkin=
stall suggested, a new syntax for 'pow' as 'power' might be=
in order, in which case, such contingencies wouldn't be as large a con=
cern. I would also argue that the above code segment is poor practice, as i=
t is relying upon the pow function to convert the two integers to doubles. =
More explicit typing would be preferred in most coding environments. Anothe=
r solution, as is implemented with powl and powf, is to use a single-letter=
abbreviation to explicitly define the types used. i.e. powi.<div><br></div=
><div>As for the graph; I mentioned in a reply to my original posting that =
I have since found an issue with the testing method I used for graphing the=
execution times for pow and powi. I have since done other tests as shown b=
elow [avg. of 20000 runs for powi, and 500 for pow (since the execution is =
longer, I decided to neglect the sample-count somewhat)]:</div><div><br></d=
iv><p style=3D"text-align:left;clear:both"><img src=3D"https://groups.googl=
e.com/a/isocpp.org/group/std-proposals/attach/146b13439f6332/Untitled2.png?=
part=3D0.1&view=3D1&authuser=3D2" alt=3D"Untitled2.png" width=3D"32=
0" height=3D"183" style=3D"margin-left: 1em; margin-right: 1em;"></p><p sty=
le=3D"text-align:left;clear:both">As you can see, powi does experience a gr=
adual increase in execution length with the increasing exponents (since it =
needs to do at worst [if an implementation were to use a simple linear appr=
oach, O(n) multiplications]).<br></p></div></blockquote><div>But really O(l=
g n) multiplications, right?</div><div>That graph looks a lot better (flatt=
er), but I'd still have to see the code before I believe it. You say yo=
ur data was</div><div><br></div><div>> gathered using "std::chrono:=
:high_resolution_clock::now()" surrounding for-loops executing the fun=
ctions</div><div><br></div><div>which pointedly omits any reference to e.g.=
<a href=3D"https://github.com/google/benchmark" rel=3D"nofollow" target=3D=
"_blank">Google Benchmark</a> or ClobberMemory/DoNotOptimize. Which suggest=
s that your benchmark might not have been measuring anything meaningful.</d=
iv><div><br></div><div>=E2=80=93Arthur</div></div></div>
</blockquote></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/y9qMRNKrS2E/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/y9qMRNKrS2E=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_blank">std-prop=
osals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7801bc16-e087-43ed-ab4f-5b5f907c125f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7801bc16-e087-=
43ed-ab4f-5b5f907c125f%40isocpp.org</a>.<br>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CADvuK0%2B1ZC60c%2B9ScSKNtu2id34E6wVn=
XzQ7WP61cKhu%2BeYARg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0%2B1=
ZC60c%2B9ScSKNtu2id34E6wVnXzQ7WP61cKhu%2BeYARg%40mail.gmail.com</a>.<br />
--000000000000d94f3f05800fa4c0--
.