Header:
|
plang/factor/real.hpp
|
Class:
|
real<float> : factor, real<double> : factor
|
float and double
is built-in data type represents floating point number. In C++ code boost::shared_ptr<real<float>>
is class corresponding to float, and boost::shared_ptr<real<double>> is class corresponding to double.
real<float> (real<double>) has float (double) type member named val which holds value of that object; threrefore, the range depends on the range of float (double) in C++.
Members
val
|
floating point number
|
Methods
float()
double()
default constructor, set val to 0
effects
val=0
template<class
T> float(T& x)
template<class T> double(T& x)
constructors includes copy constructor,
set val to x
parameters
T& x
T must be castable to float (or double)
effects
float: val=float(x)
double: val=double(x)
float cos()
double cos()
get the cosine of an angle of val radians
returns
::cos(val)
float sin()
double sin()
get the sine of an angle of val radians
returns
::sin(val)
float tan()
double tan()
get the tangent of an angle of val radians
returns
::tan(val)
float acos()
double acos()
get the arc cosine of an angle of val radians
returns
::acos(val) - range of value is [0,pi]
exceptions
range_error - domain of val is [-1,1]
float asin()
double asin()
get the arc sine of an angle of val radians
returns
::asin(val) - range of value is [-pi/2,pi/2]
exceptions
range_error - domain of val is [-1,1]
float atan()
double atan()
get the arc tangent of an angle of val radians
returns
::atan(val) - range of value is [-pi/2,pi/2]
float atan2(float y, float x)
double atan2(double y, double x)
get the arc tangent of y/x, expressed in radians
parameters
float y
double y
value representing an y-coordinate
float x
double x
value representing an x-coordinate
if both x and y equal to 0, domain error occurs
returns
::atan2(y,x) - range of value if [-pi,pi]
exceptions
range_error - if x==0 and y==0
float cosh()
double cosh()
get the hyperbolic cosine of an angle of val radians
returns
::cosh(val)
exceptions
range_error - if ::cosh(val)==HUGE_VAL
float sinh()
double sinh()
get the hyperbolic sine of an angle of val radians
returns
::sinh(val)
exceptions
range_error - if ::sinh(val)==HUGE_VAL
float tanh()
double tanh()
get the hyperbolic tangent of an angle of val radians
returns
::tanh(val)
float exp()
double exp()
get the base-e exponential function of val, which is the e number raised to the power val
returns
::exp(val)
exceptions
range_error - if ::exp(val)==HUGE_VAL
float frexp(int& exp)
double frexp(int& exp)
get significand and store exponent to exp, such that: val = significand * 2 ^ exp
parameters
int& exp - where the value of the exponent is to be stored
returns
::frexp(val,exp) - range of significand value is [0.5,1)
float ldexp(int exp)
double ldexp(int exp)
get number from significand and exponent, such that: val * 2 ^ exp
returns
::ldexp(val,exp)
float log()
double log()
get the natural logarithm of val
returns
::log(val)
exceptions
range_error - domain of val is (0,max()]
float log10()
double log10()
get the common (base-10) logarithm of val
returns
::log10(val)
exceptions
range_error - domain of val is (0,max()]
float pow(float exp)
double pow(double exp)
get val raised to the power exp, such that: val ^ exp
parameters
float exp
double exp
floating point value, exponent
if val is negative and exp is not an integral value, or if val is zero and exp is negative, domain error occurs
returns
::pow(val,exp)
exceptions
range_error
if ::fabs(::pow(val,exp))==HUGE_VAL
or val == 0 and exp <0
float sqrt()
double sqrt()
get the square root of val
returns
::sqrt(val)
exceptions
range_error - domain of val is [0,max()]
float ceil()
double ceil()
get the smallest integral value that is not less than val
returns
::ceil(val)
float abs()
double abs()
get absolute value
returns
::fabs(val)
float floor()
double floor()
get the largest integral value that is not greater than val
returns
::floor(val)
float max()
double max()
get maximum finite floating value
returns
float: std::numeric_limits<float>::max()
double: std::numeric_limits<double>::max()
float min()
double min()
get minimum finite floating value
returns
float: std::numeric_limits<float>::min()
double: std::numeric_limits<double>::min()
float infinity()
double infinity()
get value represents infinite number
returns
std::numeric_limits<>::infinity()
bool is_infinity()
check if val is infinite number
returns
::fabs(val)==infinity()