Core Math Functions

Where in the arduino are the core math functions located (sqrt, pow, cos, etc...)? I found a file called math.h, but this doesn't have the actual code... I'm looking more for math.cpp

Thanks! baum

In hardware->arduino->cores->arduino is a file called WMath.cpp, which might be what you are after. It does not appear to have any of the functions you listed though. In Arduino.h (same folder, arduino Beta only though), there are some maths functions, but not many at all:

#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))

Onions.

That's some of it. But how about the sqrt() exponent, and trig functions? any ideas?

Libraries supplied as binaries, under hardware, tools, avr. No source, if that was what you were hoping for.

ok. thx!

baum: That's some of it. But how about the sqrt() exponent, and trig functions? any ideas?

First look at AVR Libc Home Page

You can download the current version, 1.7.1 from a link on this page: AVR C Runtime Library

After unpacking, look in the avr-libc-1.7.1/libm/fplib directory.

All those files with .S file type are assembly language source for the math library functions. Names for a good many are pretty obvious:

sqrt.S has source for sqrt() log.S has source for log() sin.S has source for sin()

etc.

Regards,

Dave