math.h

Compiling in c++ with mysql, pthreads and gtk

Have someone ever done this before??? I am trying to use MinGW to compile a program using the MySQL libraries. I keep getting the message that the function 'rint' is redefined. Ok it's true that the function is in both files config-win.h, from MySQL and math.h from the standard library, but both of them are suppose to be libraries with ...

Problem with conflict between mysql and math.h

Hello there... The problem is that the compiler says that there is a redefinition of a function between a library that belongs to MySQL and math.h from the std library. I have been over this for two days and I still can't figure it out. Has this ever happened to anyone? This is the output from the compiler C:\mingw\bin\mingw32-m...

what is the difference between atan and atan2 in c++ ?

what is the difference between atan and atan2 in c++ ? ...

erf(x) and math.h

According to this site the error function erf(x) comes from math.h. But actually looking in math.h, it isn't there, and gcc cannot compile the following test program while g++ can: #include <math.h> #include <stdio.h> int main(int argc, char* argv[]) { double x; double erfX; x = 1.0; erfX = erf(x); printf("erf(%f) = %f", x, ...

Why do you have to link the math library in C?

If I put stdlib.h or stdio.h, I don't have to link those but I have to link when I compile: gcc test.c -o test -lm What is the reason for that? Why do I have to explicitly link the math library but not the other libraries? Any links explaining why would be appreciated. Thanks for the help :) ...

Calling functions from within function(float *VeryBigArray,long SizeofArray) from within objC method fails with EXC_BAD_ACCESS

Ok I finally found the problem. It was inside the C function(CarbonTuner2) not the objC method. I was creating inside the function an array of the same size as the file size so if the filesize was big it created a really big array and my guess is that when I called another function from there, the local variables were put on the stack w...

Visual C++ math.h bug

Hello! I was debugging my project and could not find a bug. Finally I located it. Look at the code. You think everything is OK, and result will be "OK! OK! OK!", don't you? Now compile it with VC (i've tried vs2005 and vs2008). #include <math.h> #include <stdio.h> int main () { for ( double x = 90100.0; x<90120.0; x+=1 ) { ...

Is there a Java equivalent of frexp?

Is there a Java equivalent of the C / C++ function called frexp? If you aren't familiar, frexp is defined by Wikipedia to "break floating-point number down into mantissa and exponent." I am looking for an implementation with both speed and accuracy but I would rather have the accuracy if I could only choose one. This is the code sampl...

Floating point again

Yesterday I asked a floating point question, and I have another one. I am doing some computations where I use the results of the math.h (C language) sine, cosine and tangent functions. One of the developers muttered that you have to be careful of the return values of these functions and I should not make assumptions on the return values...

[C++] Is it possible to roll a significantly faster version of modf

In an app I'm profiling, I found that in some scenarios this function is able to take over 10% of total execution time. MSVC++ 2008 compiler is being used, for reference... I don't recall if modf maps to a single instruction or if there is likely any way to make it faster. see also here for similar question on sqrt function Unlike sqr...

Why does this code sometimes return NaN?

This often returns NAN ("Not A Number") depending on input: #define PI 3.1415f GLfloat sineEaseIn(GLfloat ratio) { return 1.0f-cosf(ratio * (PI / 2.0f)); } I tried making PI a few digits smaller to see if that would help. No dice. Then I thought it might be a datatype mismatch, but float and glfloat seem to be equivalent: gl.h t...

When do I use fabs and when is it sufficient to use std::abs?

I assume that abs and fabs are behaving different when using math.h. But when I use just cmath and std::abs, do I have to use std::fabs? or fabs? Or isn't this defined? ...

sqrt() function not working with variable arguments

I don't know if I'm missing something obvious, but it appears that I'm unable to compute square roots of a variable in C; the sqrt() function only seems to work on constants. This is my code: #include <math.h> #include <stdio.h> int main() { double a = 2.0; double b = sqrt(a); printf("%f", b); return 0; } When I run t...