Dom::Float -- the real floating
point numbers
IntroductionDom::Float is the set of real floating point numbers
represented by elements of the domain DOM_FLOAT.
Creating
ElementsDom::Float(x)
Parametersx |
- | an expression which can be converted to a
DOM_FLOAT by the function float. |
Cat::DifferentialRing
Related
DomainsDom::Complex, Dom::Integer, Dom::Numerical, Dom::Rational, Dom::Real
DetailsDom::Float is the domain of real floating point
numbers represented by expressions of type DOM_FLOAT.Dom::Float has category Cat::Field out of pragmatism. This domain
actually is not a field because bool(1.0 = float(3) /
float(3)) returns FALSE for example.Dom::Float are usually not created
explicitly. However, if one creates elements using the usual syntax, it
is checked whether the input expression may be converted to a floating
point number. This means Dom::Float is a facade domain
which creates elements of domain type DOM_FLOAT.Dom::Float is trivial,
it contains constants only.Dom::Float has the domain Dom::Numerical as its super domain,
i.e., it inherits each method which is defined by
Dom::Numerical and not implemented by
Dom::Float. Methods described below are re-implemented by
Dom::Float.the unit element; it equals 1.0.
The zero element; it equals 0.0.
random()convert(any x)x to a number of type
Dom::Float. If the conversion fails, FAIL is
returned.float(x) evaluates to a real floating
point number of type DOM_FLOAT, this number is the result
of the conversion.convert_to(dom x, any
T)x to an
element of type T, or, if T is not a domain,
to the domain type of T. If the conversion fails, then
FAIL is returned.T: DOM_FLOAT, Dom::Float and Dom::Numerical.
Example
1Creating some floating point numbers using
Dom::Float. This example also shows that
Dom::Float is a facade domain.
>> Dom::Float(2.3); domtype(%)
2.3
DOM_FLOAT
>> Dom::Float(sin(2/3*PI) + 3)
3.866025404
>> Dom::Float(sin(x))
Error: illegal arguments [Dom::Float::new]
Example
2By tracing the method Dom::Float::testtype
we can see the interaction between testtype and
Dom::Float::testtype.
>> prog::trace(Dom::Float::testtype): delete x: testtype(x, Dom::Float); testtype(3.4, Dom::Float); prog::untrace(Dom::Float::testtype):
enter 'Dom::Float::testtype' with args : x, Dom::Float
leave 'Dom::Float::testtype' with result : FAIL
FALSE
enter 'Dom::Float::testtype' with args : 3.4, Dom::Float
leave 'Dom::Float::testtype' with result : TRUE
TRUE
Super-DomainAx::canonicalRep
, Ax::systemRep,
Ax::canonicalOrder,
Ax::efficientOperation("_divide"),
Ax::efficientOperation("_mult"),
Ax::efficientOperation("_invert")