Menu

Math.h functions

2006-08-15
2012-09-26
  • Nobody/Anonymous

    How can I see the functions you can use with libraries, particularly math.h? I want to know how they do some stuff, but I can't find these functions anywhere in the libraries. Where can I look to learn some of these functions?

     
    • Nobody/Anonymous

      Thank you Clifford, that's very helpful!

       
    • Wayne Keen

      Wayne Keen - 2006-08-15

      You understand that "math.h" is not a library, but rather a header?

      Are you wanting to see how the functions are called, or how they are actually implimented?

      Wayne

       
    • Nobody/Anonymous

      No I did not know that, when I googled math.h, one of the titles said "The Mathematics Library (math.h)...", but I guess they were wrong.

      Anyway, I'd like to know how they are actually implemented, such as sqr(x) => x*x.

       
    • Nobody/Anonymous

      x*x=pow(x,2)

       
    • Nobody/Anonymous

      No I'd like to know several functions, not just a few. If there isn't an easy way of getting this onfo, that's okay. I was just curious about how some of the functions are done.

       
    • Wayne Keen

      Wayne Keen - 2006-08-16

      Take a moment and take a gander at the section in the thread titled "Please Read Before Posting a Question", on the Compile Log, Including Headers and Linking Libaries, it will get you started on understanding the difference beween a header and a library.

      You do know by the way that a header (which describes the interface to the associated functions in the library), can be edited just like any text file.

      Wayne

       
    • Anonymous

      Anonymous - 2006-08-16

      >> No I did not know that, when I googled math.h, one of the titles said "The Mathematics Library (math.h)...", but I guess they were wrong.

      They were not 'wrong' as such - to say that would be somewhat pedantic - math.h is the header you need to include in your source code in order to use the standard math library. It contains declarations (i.e. prototypes) of the functions that are defined in the library. The compiler uses these declarations to check the calls you make, and places 'unresolved reference' in the code. The linker (which is a separate stage from compilation) then takes all your compiled object code and the library code and cross-references then to resolve these references with direct calls to the code.

      The libraries themselves come in two forms - static libraries (or archives) which by convention in GNU have the .a extension (others generally use .lib), or Dynamic Link Libraries (.dll). DLLs generally have a small static library called an export library, which is linked with teh code to enable the DLL to be linked automatically at runtime.

      >> Anyway, I'd like to know how they are actually implemented, such as sqr(x) => x*x.

      These libraries are pre-compiled binary object code, so you cannot determine the source implementation by inspecting them. Moreover the standard C library implementation used by MinGW is Microsoft's MSVC++ C runtime (in MSVCRT.DLL). This is not open source code, so you cannot see how it was implemented.

      However, if you want to simply see an implementation, there are a number of open source C libraries whose code you could inspect.

      GNU C library: http://www.gnu.org/software/libc/
      Newlib C library: http://sources.redhat.com/newlib/

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.