Where is pow function defined and implemented in C?

后端 未结 8 993
生来不讨喜
生来不讨喜 2021-01-14 11:29

I read that the pow(double, double) function is defined in \"math.h\" but I can\'t find its declaration.

Does anybody know where this function declared? And where i

8条回答
  •  时光说笑
    2021-01-14 11:45

    Here's a C implementation for fdlibm: http://www.netlib.org/fdlibm/e_pow.c

    For what it's worth, when v8 dropped its cos/sine tables, it pulled from fdlibm's implementation to do so: https://code.google.com/p/v8/source/detail?r=22918

    From the change commit comments: "Implement trigonometric functions using a fdlibm port."

    Mozilla on the other hand calls the cstdlib math functions, which will have variable performance by build and system (ex: may or may not invoke the chip-level implementations of transcendental functions). While C# bytecode seems to make explicit references to chip-level functions when it can. However, "pow" is not one of those, iirc (doesn't seem to have an chip-level function) and is implemented elsewhere.

    See also: https://bugzilla.mozilla.org/show_bug.cgi?id=967709

    For a cos/sine discussion in the Mozilla community, comparison of Mozilla's implementation vs old v8 implementation.

    See also: How is Math.Pow() implemented in .NET Framework?

    Intrinsic functions are chip-level, actually implemented on the processor. (We don't necessarily need lookup tables any more.)

提交回复
热议问题