Questions tagged [math.h]

For questions relating to functions declared by the math.h header file of C programming language.

Most of the mathematical functions are placed in math.h header (cmath header in C++).
math.h header file has following functions:

int abs (int x);                    
long labs (long x);

double fabs (double x);
double sin (double x);
double cos (double x);
double tan (double x);
double asin (double x);
double acos (double x);
double atan (double x);
double sinh (double x);
double cosh (double x);
double tanh (double x);

double exp (double x);              ex
double log (double x);              ln x
double log10 (double x);            log x

double pow (double x,double y);     xy
double sqrt(double x);              square root of x
double fmod(double x, double y);    x mod y

double ceil (double x);
double floor(double x);
310 questions
0
votes
1 answer

Replacing an math.h exp call with a lookup table

I was wondering if there's any point in modifying code to use a lookup table for math.h exp, or if it was done automatically by clang++ when given the -O3 flag. If it's not, is there a #pragma that does this? clarification I was talking about…
Alex Petrosyan
  • 473
  • 2
  • 20
0
votes
1 answer

Can't figure out the calculation of the pow() function in C

Today, I found some strange calculations which is not known to me (Also didn't find any issues in SO regarding this) regarding pow() function of math.h in C. The code I was experimenting was: #include #include int main(){ …
UkFLSUI
  • 5,509
  • 6
  • 32
  • 47
0
votes
0 answers

sqrt Function from math.h Library Causes Entire Program to Stop Functioning After Compiling

I am using Code Composer Studio to work with an MSP430 MCU. These are the specs that I am working with: CCS version: 5.5 Compiler version: TI v4.1.9 Compiler Optimization Settings: Optimization = 0 MSP430: MSP430F5528 I'm starting with a…
Kyle G
  • 71
  • 10
0
votes
1 answer

C++ - extern int (double)

I'm receiving an error trying to build a program due to file mingw/include/math.h The error states include/math.h:379:20: error: expected identifier or '(' before numeric constant The error is from the following lines extern int __cdecl __isnan…
Treyten Carey
  • 641
  • 7
  • 17
0
votes
1 answer

How to get Geany to link with the math library in C?

I'm using the Linux Mint distribution, and writing a program in C. However, I'm having trouble with the compilation part. Specifically, none of the math.h functions seem to work (like sqrt() or pow()). I know that if I were compiling through the…
Chris K.
  • 11
  • 1
  • 1
0
votes
1 answer

Qt: Undefined reference to atof, log2 & log2f on android linking to FFmpeg

Trying to build my Qt application for android linking to FFmpeg. I get the following linker errors on android. libavformat/hls.c:783: error: undefined reference to 'atof' libavcodec/ffv1enc.c:476: error: undefined reference to…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
0
votes
0 answers

Why are 64bit VC++ trigometric function (cmath/math) runtime (hardware) depend

We have been programming the control software for cutting machine since many years. We are developing for Windows only and using Visual Studio 2015 and Qt5.6. Since we plan to distribute our SW as 64bit we have some problems with certain automated…
Mario
  • 1
  • 3
0
votes
1 answer

Where is the definition of function nanf() on linux

I am trying to look for definition and declaration of the function nanf() - return 'Not a Number function, which is related to the floating point functionality on Linux gcc compiler environment - (glibc). I need to use similar/same definition for…
goldenmean
  • 18,376
  • 54
  • 154
  • 211
0
votes
1 answer

How to refresh the file math.h

Possible Duplicate: Why Am I Getting Link Errors When Calling Function in Math.h? Hello, I have a problem in C (gcc), when I compile a program that includes Math.h and uses functions from there, it says "undefined reference to...". it happens for…
shkk
  • 313
  • 1
  • 3
  • 4
0
votes
0 answers

Redefinition of the symbols in math.h

I'm trying to build a single .cpp file that includes several other files via clang for NDK. First of all, I did that before with other files so it is not the problem that I'm doing it like this and not using ndk-build. Once I tried to build the…
s1ddok
  • 4,615
  • 1
  • 18
  • 31
0
votes
1 answer

Why is my code returning a number lower than what it should return?

So I am doing an assignment for a programming course and I am having trouble with one line of my code. the answer should be (if my math is correct) 40 but the program returns 39. example: 18.33 * 40 *52 = 38126.4 I then use this code double wage =…
AncientOwl
  • 13
  • 4
0
votes
0 answers

Visual C++ Math functions run faster in Win32

There's something I've noticed when profiling a VS2013 program with VTune that I haven't been able to find a proper explanation for. Essentially, one of the non-negligible hotspots for the program are the mathematical functions. cos, sin, sqrt, etc.…
spliblib
  • 43
  • 5
0
votes
2 answers

Errors with Downloading OpenCV in Ubuntu

I have been following these instructions to download OpenCV 3.1.0: http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/ However, after running the make -j4 command the code processes until 14%, the output looks like…
Rehaan Ahmad
  • 794
  • 8
  • 23
0
votes
1 answer

Why am I getting the error, "undefined reference to `pow' collect2: error: ld returned 1 exit status make: *** [p1] Error 1"?

Here is my makefile: CC=gcc CFLAGS=-g LDFLAGS=-lm EXECS= p1 all: $(EXECS) clean: rm -f *.o $(EXECS) 14:32:16 **** Build of configuration Default for project CH3-Programs **** make p1 gcc -g -ggdb -lm p1.c -o p1 /tmp/ccNTyUSA.o: In…
0
votes
1 answer

CC3200. compiler warnings when use freertos with math.h

I have to use some functions from math library on a CC3200 Project. This project has to use freertos and the IDE is CCS. With this combination, the compiler show these warnings: /ymath.h", line 550: warning #225-D: function "_ftoi" declared…