public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* pow(3): warn against ineffecient uses?
@ 2017-03-29 19:35 Joachim Wuttke
       [not found] ` <ee3b127b-5e9e-e82d-1731-172185c8ebd2-97/bSmCnXvjoK6nBLMlh1Q@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Joachim Wuttke @ 2017-03-29 19:35 UTC (permalink / raw)
  To: linux-man-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Maybe it would be appropriate to warn against inefficient
uses of the function pow. To make a very first proposal
for a paragraph to be added to pow(3):

In time-critical code, pow with small integer or simple
fractional exponents should be avoided in favor of
straightforward multiplication, division or square or
cubic roots: prefer x*x over pow(x,2), 1/x over pow(x,-1),
sqrt(x) over pow(x,0.5), or cbrt(x*x) over pow(x,2.0/3).

My motivation for this proposal comes from student code
in which I have seen exactly these mistakes.

- Joachim


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5110 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-10 12:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-29 19:35 pow(3): warn against ineffecient uses? Joachim Wuttke
     [not found] ` <ee3b127b-5e9e-e82d-1731-172185c8ebd2-97/bSmCnXvjoK6nBLMlh1Q@public.gmane.org>
2017-03-31 11:17   ` Florian Weimer
     [not found]     ` <871stdn197.fsf-ZqZwdwZz9NfTBotR3TxKnbNAH6kLmebB@public.gmane.org>
2017-04-10 12:13       ` Michael Kerrisk (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox