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

Fmod as While Loop Condition Error

I'm having an issue with fmod() where it doesn't "suit" the conditions in a while loop when used with a parameter. I've recreated the snippet below, which causes the same error as my main program. #include int main() { double foo =…
Dwayne H
  • 235
  • 2
  • 11
0
votes
4 answers

C++: Expression must be a modifiable lvalue

I am making a text based simple operation/trig calculator. I am getting the error: "Expression must be a modifiable lvalue" when I attempt to sqrt the squared variables. Here is my current code: (the error highlights the sqrt) double a, b,…
Lindy
  • 11
  • 2
0
votes
2 answers

Integrate FDLIBM library to iOS

I am trying to integrate FDLIBM library (http://www.netlib.org/fdlibm/) into my Swift based (with some objc and c code too) iOS app. However, some of functions there are conflicting with math.h which is automatically included in iOS, i.e. sin,…
Zhao
  • 904
  • 1
  • 11
  • 34
0
votes
0 answers

Evaluate math functions in gdb

This question was asked a long time ago but were not really answered. I get some weird wrong results when I try to evaluate math functions in gdb. I started with the following file #include #include int main() { double x ; …
Olivier Esser
  • 431
  • 1
  • 4
  • 12
0
votes
1 answer

I am fairly new to code blocks.I have spent too much time on this error .Can someone point out what is my mistake in this code

I am new to codeblocks. I was trying to find height of a BST and used max() function. But while compiling CodeBlock throws error.I am using Windows machine.I know linking maths.h manually will solve the issue.I know how to link math.h manually using…
user3847870
  • 368
  • 1
  • 6
  • 21
0
votes
2 answers

C - Rounding issues (CS50)

I have been Googling this for days now and I am lost. So doing CS50 online and can't seem to get a handle on this rounding of numbers. My program is messing up multiplying floats like 2.10 with integers like 100 it would output 209.xxxxxxxx Now like…
0
votes
1 answer

Pythagorean trigonometric identity rule broken in VS2013

After upgrading to Visual Studio 2013 I noticed that some basic math functions became working differently, for example sin() from or . That might be a good changes, but some tests showed of one of the main mathematical rule is…
Andrey Lyubimov
  • 663
  • 6
  • 22
0
votes
1 answer

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…
user360092
  • 87
  • 8
0
votes
1 answer

C++ math.h on OS X 10.8.5

I have a C++ program that will not compile under OS X 10.8.5 with the g++ compiler. The problem seems to be with the math.h header file. This is the version of g++ is g++ -v Using built-in…
JMD
  • 405
  • 1
  • 9
  • 17
0
votes
0 answers

Perf on a code using exp function from Math.h shows time spent in resolving conflicts e_exp,w_exp

my code computes in a loop exp of a large data array and when I tried to do Perf to profile the code, I get to see Symbols conflicting in multiple…
Quest03
  • 3
  • 2
0
votes
1 answer

Functions from math.h returns invalid result with C++/clr

I am working in a project where I must interface between managed code and unmanaged code. I am currently having a strange issue with math.h. Some functions will floating numbers will returns 0 (ex: 2.1219957934356005e-314) and randomly... By…
Nic007
  • 634
  • 5
  • 13
0
votes
1 answer

'floor': identifier not found

My code was working fine until suddenly I am receiving this message when compiling: c:\program files (x86)\microsoft visual studio 12.0\vc\include\math.h(700): error C3861: 'floor': identifier not found I tried to exclude math.h, but I got the…
Parsa
  • 95
  • 1
  • 5
0
votes
0 answers

C: Math.h has different exception specifiers

I am trying to compile my own code using some functions in this library: tsnnls This libraries also uses other libraries: Lapack, Blas, Argtable2, TAUCS It seems that there are some incompatiablity in error handling of function between math.h and…
Garima Singh
  • 1,410
  • 5
  • 22
  • 46
0
votes
1 answer

intelliSense: no instance of overloaded function "sqrt" matches the argument list argument types are: (double *)

What is wrong with this code ??!!! i am making a program trying to solve quadratic equation and see this error and couldn't solve it shall i change to float or what ?? #include #include #include void…
Tadros Ebrahim
  • 45
  • 1
  • 1
  • 6
0
votes
2 answers

#include in Visual Studio 2012

This is a program I wrote : #include "stdafx.h" #include "math.h" int main () { int phi; float c; scanf_s("%d",&phi); c=(pow(sin(phi)*cos(phi),-2))-(pow(tan(phi),2)+pow(tan(phi),-2)); if (c==2) { printf("C is…