/**
* This module contains strategies for operating on real numbers.
*
* In Stratego, real numbers are primitive terms, separate from
* integers. The precision of the reals match that of the underlying
* runtime platform, which currently always is the ANSI C library.
*
* @author Eelco Visser <visser@acm.org>
* @author Karl Trygve Kalleberg <karltk@cs.uu.nl> - documentation
*/
module term/real
strategies
/** Predicate to check if the current term is a real number.
*
* @type Real -> Real
*/
is-real = ?x; prim("SSL_is_real",x)
/** Compute cosine of a real number.
*
* @type Real -> Real
*/
cos = ?x; prim("SSL_cos",x)
/** Compute sine of a real number.
*
* @type Real -> Real
*/
sin = ?x; prim("SSL_sin",x)
/** Compute square of a real number.
*
* Note: The number sqrt is applied to must be non-negative, as complex
* numbers are not supported.
*
* @type Real -> Real
*/
sqrt = ?x; prim("SSL_sqrt",x)
/** Compute arc tangent of a par of real numbers. The result, when applied to
* the pair (x,y), is the arc tangent of y/x, expressed as radians between
* -PI and PI. The signs of the parameters x and y are used to determine the
* correct quadrant.
*
* @type Real -> Real
*/
atan2 = ?(x,y); prim("SSL_atan2",x,y)
/** Convert a real to a string with default (maximal) precision.
*
* @type Real -> String
*/
real-to-string = ?x; prim("SSL_real_to_string",x)
/** Convert a real to a string with given precision.
*
* The term argument prec specifies the number of digits after the
* period is required. The result is rounded.
*
* Example: <real-to-string(2)> 12.124 => "12.12"
*
* @type prec Int
* @type Real -> String
*/
real-to-string(|prec) = ?x; prim("SSL_real_to_string_precision",x,prec)
/** Construct a real from a string.
*
* Example: <string-to-real> "123.0e+02"
*
* @type String -> Real
*/
string-to-real = ?x; prim("SSL_string_to_real",x)
/** Construct a real from an int.
*
* @type Int -> Real
*/
real = ?x; prim("SSL_real",x)