- How to improve pow() - 11 Updates
| Cholo Lennon <chololennon@hotmail.com>: Sep 07 10:36PM -0300 On 9/7/22 12:19, Bonita Montero wrote: > That's not necessary any more since I've developed some code > that is more than twice as fast as the MSVC implementation. >> A competent programmer would have no problem doing that. Don't feed the troll, she has serious mental issues. After reading her answer I completely blocked her, she's not OK. |
| Muttley@dastardlyhq.com: Sep 08 09:21AM On Wed, 7 Sep 2022 18:07:43 +0200 >>> It's simply that you're both too stupid to adapt my style. >> Its quite clear you love complexity. >I've written complex code, but this absolutely isn't complex. I'm not talking about the mathematics, I'm talking about the needless use of a local lambda function. Why not do it inline? And wtf is the bool_constant nonsense about with false_type and true_type? You don't need any of that. |
| Juha Nieminen <nospam@thanks.invalid>: Sep 08 09:26AM > I'm not talking about the mathematics, I'm talking about the needless use of > a local lambda function. Why not do it inline? And wtf is the bool_constant > nonsense about with false_type and true_type? You don't need any of that. Yeah. Normal people do a simpler run<true>() and run<false>(). Less writing, less confusing, simpler. |
| Muttley@dastardlyhq.com: Sep 08 10:29AM On Thu, 8 Sep 2022 09:26:41 -0000 (UTC) >> nonsense about with false_type and true_type? You don't need any of that. >Yeah. Normal people do a simpler run<true>() and run<false>(). >Less writing, less confusing, simpler. You don't even need that. She's setting the bool based on whether e >= 0 then setting eAbs to e or -e based on the bool. Why not just do "eAbs = e"? And since e isn't changed you can use it in the "v = " test at the bottom too. And there's zero reason for a lambda and UNROLL_FACTOR does nothing. Could be rewritten as follows: double powPow( double d, int e ) { double v = 1.0, sq = d; for(unsigned aAbs=e; eAbs; eAbs >>= 1, sq *= sq ) v *= (int)(eAbs & 1) * sq + (int)(eAbs & 1 ^ 1); return (e >= 0 ? v : 1.0 / v); } |
| Richard Damon <Richard@Damon-Family.org>: Sep 08 08:50AM -0400 > v *= (int)(eAbs & 1) * sq + (int)(eAbs & 1 ^ 1); > return (e >= 0 ? v : 1.0 / v); > } Is that going to work for negative e? if e == -1, then aAbs == UNSIGNED_MAX, and the return value will be something like 1 / (d^UNSIGNED_MAX) instead of 1/d. |
| scott@slp53.sl.home (Scott Lurndal): Sep 08 01:25PM >I'm not talking about the mathematics, I'm talking about the needless use of >a local lambda function. Why not do it inline? And wtf is the bool_constant >nonsense about with false_type and true_type? You don't need any of that. Not to mention the unused constant UNROLL_FACTOR. |
| Muttley@dastardlyhq.com: Sep 08 03:25PM On Thu, 8 Sep 2022 08:50:20 -0400 >Is that going to work for negative e? >if e == -1, then aAbs == UNSIGNED_MAX, and the return value will be >something like 1 / (d^UNSIGNED_MAX) instead of 1/d. I didn't compile and run it , but something along those lines will do the exact same job as Bonitas code and probably more efficiently. |
| Bonita Montero <Bonita.Montero@gmail.com>: Sep 08 06:15PM +0200 >> I've written complex code, but this absolutely isn't complex. > I'm not talking about the mathematics, I'm talking about the needless use of > a local lambda function. ... That's not needles, that's my style which saves a lot of code. |
| Bonita Montero <Bonita.Montero@gmail.com>: Sep 08 06:16PM +0200 Am 08.09.2022 um 11:26 schrieb Juha Nieminen: >> nonsense about with false_type and true_type? You don't need any of that. > Yeah. Normal people do a simpler run<true>() and run<false>(). > Less writing, less confusing, simpler. There's nothing confusing with my code and the way I did it saves one non-predictible branch and results in half the code size if you do that manually. |
| Bonita Montero <Bonita.Montero@gmail.com>: Sep 08 06:17PM +0200 Am 08.09.2022 um 15:25 schrieb Scott Lurndal: > Not to mention the unused constant UNROLL_FACTOR. That's a line of code I forgot to remove from by before version. |
| Bonita Montero <Bonita.Montero@gmail.com>: Sep 08 06:19PM +0200 Am 08.09.2022 um 03:36 schrieb Cholo Lennon: >>> A competent programmer would have no problem doing that. > Don't feed the troll, she has serious mental issues. After > reading her answer I completely blocked her, she's not OK. I don't understand why that is trolling. But I think people being provoked by that have like you have mental issues, not me. |
| You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment