GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
M_REAL(3) FreeBSD Library Functions Manual M_REAL(3)

M_Real
Agar-Math real number operations

#include <agar/math.h>

Real numbers in Agar-Math are most often described using the M_Real type. Depending on which precision mode the library was compiled against (see the --with-<mode>-fp configure option), M_Real may expand to float (32-bit, SINGLE_PRECISION is defined), double (64-bit, DOUBLE_PRECISION is defined) or long double (80-bit or 128-bit, QUAD_PRECISION is defined).

Most Agar-Math structures use M_Real to represent floating-point numbers. The real and imaginary parts of M_Complex(3), and the elements of M_Vector(3) and M_Matrix(3) are all stored as M_Real values. Note, however, that fixed-size types such as M_Vector2, M_Vector3, M_Vector4, and M_Matrix44 may or may not use a different precision (depending on the availability of SIMD instructions such as AltiVec and SSE). The general M_Vector and M_Matrix types are always guaranteed to use M_Real.

M_Real
M_ReadReal(AG_DataSource *ds);


void
M_CopyReal(AG_DataSource *ds, M_Real *r);


void
M_WriteReal(AG_DataSource *ds, M_Real r);

The M_ReadReal() function reads a complex number from an AG_DataSource(3) and returns it. The M_CopyReal() variant returns the number in r. M_WriteReal() writes a real number to a data source.

The library defines the following fundamental constants:
Euler's constant
log_2 e
log_10 e
log_e 2
log_e 10
pi
pi/2
pi/4
1/pi
2/pi
2/sqrt(pi)
sqrt(2)
1/sqrt(2)

The following constants describe the limitations of the memory format for the current precision mode:

Minimum exponent.
Maximum exponent.
Precision of the significand in bits.
M_PRECISION/2 (rounded up).
Highest representible number.
Machine epsilon, or unit roundoff.
A very small number, close to M_MACHEP.
A very large number.
Representation of infinity.

M_Real
M_Log(M_Real x);


M_Real
M_Exp(M_Real x);


M_Real
M_ExpM1(M_Real x);


M_Real
M_Sqrt(M_Real x);


M_Real
M_Cbrt(M_Real x);


M_Real
M_Sin(M_Real x);


M_Real
M_Cos(M_Real x);


M_Real
M_Tan(M_Real x);


M_Real
M_Sinh(M_Real x);


M_Real
M_Cosh(M_Real x);


M_Real
M_Tanh(M_Real x);


M_Real
M_Cot(M_Real x);


M_Real
M_Sec(M_Real x);


M_Real
M_Csc(M_Real x);


M_Real
M_Asin(M_Real x);


M_Real
M_Acos(M_Real x);


M_Real
M_Atan(M_Real x);


M_Real
M_Asinh(M_Real x);


M_Real
M_Acosh(M_Real x);


M_Real
M_Atanh(M_Real x);


M_Real
M_Atan2(M_Real y, M_Real x);


M_Real
M_Hypot2(M_Real x, M_Real y);


M_Real
M_Fabs(M_Real x);


M_Real
M_Sgn(M_Real x);


M_Real
M_Pow(M_Real x, M_Real y);


M_Real
M_Frexp(M_Real x, int *exp);


M_Real
M_Ldexp(M_Real x, int *exp);


M_Real
M_Ceil(M_Real x);


M_Real
M_Floor(M_Real x);


int
M_IsNaN(M_Real x);


int
M_IsInf(M_Real x);

M_Log() returns the natural logarithm of x.

M_Exp() returns the value of e, raised to the power of x.

The M_ExpM1() routine returns the equivalent of M_Exp(x)-1. Numerical roundoff error is prevented in the case of x being near zero.

M_Sqrt() returns the square root of x. M_Cbrt() returns the cube root of x.

M_Sin(), M_Cos() and M_Tan() return the sine, cosine and tangent of x (given in radians). M_Sinh(), M_Cosh(), M_Tanh() return the hyperbolic sine, cosine and tangent of x.

M_Cot(), M_Sec() and M_Csc() return the cotangent, secant and cosecant of x.

M_Asin(), M_Acos() and M_Atan() return the arc sine, arc cosine and arc tangent of x. M_Asinh(), M_Acosh() and M_Atanh() return the hyperbolic arc sine, arc cosine and arc tangent of x.

M_Atan2() returns the equivalent of Atan(y/x), except that the sign of the result is determined from the signs of both arguments.

M_Hypot2() computes the length of the hypotenuse of a right-angle triangle with the right-angle side lengths of x and y.

M_Fabs() returns the absolute value of x.

The sign function M_Sgn() returns +1.0 if the sign of x is positive or -1.0 if the sign is negative.

M_Pow() returns x raised to the power of y.

M_Frexp() returns the normalized fraction for x, and writes the exponent to exp.

M_Ldexp() returns the result of multiplication of x by 2 to the power exp.

M_Ceil() rounds x up to the nearest integer. M_Floor() rounds down to the nearest integer.

M_IsNan() evaluates to 1 if x is "not a number".

M_IsInf() evaluates to 1 if x represents infinity.

AG_DataSource(3), AG_Intro(3), M_Complex(3), M_Geometry(3), M_Matrix(3), M_Quaternion(3), M_Vector(3)

The M_Real structure first appeared in Agar 1.3.4.
July 18, 2009 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.