Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Runtime

Name: Anonymous 2012-08-25 0:34

when i use pow(x,y) in C, is such a thing calculated in constant or linear runtime?

Name: Anonymous 2012-08-25 0:42

Such a thing is implementation dependent.

It wouldn't surprise me if most compilers took advantage of y being a constant, if y is in an integer you could do it recursively in logarithmic time (if you allow the result to be slightly altered, floating point math is rarely associative).

Name: Anonymous 2012-08-25 2:37

pow(x, y) is a function call (or a macro but usually not), so anything can happen. If you want to know exactly what's going on, get a debugger.

Name: Anonymous 2012-08-25 3:07

Never use pow unless the exponent isn't constant and you need full IEEE 754 precision. Most implementations are really slow.

Name: NGGER MATURE CRISIS 2012-08-25 3:12

>>2
>>1
>>4
FUCK SHITHEAP? I BETU Y DONT EVEN OPTOMIZED YOUR QUPOTES! AND YET REFUSE PAY ATTENTION NGGER MATURE FCRISSE>>3

Name: gcc -O3 --funroll-quotes 2012-08-25 10:17

>>5
Optimized quotes.

Name: Anonymous 2012-08-25 13:57

>>6
If /prog/ had a post compiler, it would probably do that automatically for the user.

Name: Anonymous 2012-08-25 14:57

>>7
The post compiler would show the optimized output.

Name: Anonymous 2012-08-25 15:41

Name: Anonymous 2012-08-25 15:45

I feel kawaii.

Name: Anonymous 2012-08-25 20:31

x^y can be implemented in hardware giving a constant time result (with an enormous constant). I doubt it's done that way though since it's so bad in area requirements and much simpler to do using a digit recurrence algorithm in microcode (slightly larger upper bound constant)

Name: Anonymous 2012-08-25 22:09

>>11

technically, if x and y have a limited range of values, like 0, 1, 2, ... 2^64, for example, then the performance of pow(x, y) can always be bounded by a constant, assuming that pow(x, y) terminates for each x and y.

Name: Anonymous 2012-08-25 22:12

>>1-12                `
>2012
>not just looking up pre-computed values in a hash table

ISHYGDDT

Name: Anonymous 2012-08-25 23:51

>>13
Back to /g/, ``please"!

Name: Anonymous 2012-08-27 15:47

OP here, could someone show a typical x86 assembly algorithm and state it's runtime?

Name: Anonymous 2012-08-27 15:51

>>15
rep movsd
MSVCRT

Don't change these.
Name: Email:
Entire Thread Thread List