Software Floating-point Numbers and Their Constructors - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : float

Software Floating-point Numbers and Their Constructors

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Float(M, E)

SFloat(M, E)

x.yen

x.yEn

Parameters

M

-

expression

E

-

expression

x

-

(optional) integer constant

y

-

(optional) unsigned integer constant

n

-

(optional) integer constant

Description

• 

An arbitrary-precision software floating-point number (an object of type sfloat) is represented internally in Maple by a pair of integers (the mantissa M and the exponent E).

• 

The Float(M, E) command can be used to construct the floating-point number M * 10^E.

  

If the mantissa parameter is of type imaginary, Float(M, E) returns I * Float(Im(M), E).

  

If the mantissa is of type nonreal, Float(M, E) returns Float(Re(M), E) + I * Float(Im(M), E).

  

The SFloat(M, E) command is equivalent to the Float(M, E) function.

  

In Maple, a software floating-point number (see type[sfloat]) and a general floating-point number (see type[float]) are considered to be the same object. Maple also has hardware floating-point numbers, of type hfloat (see type[hfloat]), which can be constructed using the HFloat constructor.

• 

The maximum number of digits in the mantissa of a software float, and the maximum and minimum allowable exponents, can be obtained from the Maple_floats routine.

• 

Software floating-point numbers can also be created by entering x.yEn or x.yen, where n is the integer exponent. All three parameters are optional in the calling sequence. If y is omitted in the calling sequence, then the decimal point must also be omitted (for example, 1e0 not 1.e0).

• 

To obtain the mantissa and exponent fields of a software float, use SFloatMantissa and SFloatExponent, respectively.

• 

The presence of a floating-point number in an expression generally implies that the computation will use floating-point evaluation. The floating-point evaluator, evalf, can be used to force computation to take place in the floating-point domain.

• 

The number of digits carried in the mantissa for floating-point arithmetic is determined by the Maple environment variable Digits (default is 10).

• 

Maple includes a variety of numeric functions to use with floating-point numbers.

CopySign

Default0

DefaultOverflow

DefaultUnderflow

denom

frem

ilog10

ilog2

Im

NextAfter

numer

NumericClass

OrderedNE

Re

Scale10

Scale2

SFloatExponent

SFloatMantissa

Unordered

 

Notes regarding infinity

  

The quantity Float(infinity) represents a floating-point infinity.  This value is used to indicate a floating-point value that is too large to be otherwise represented.  It does not necessarily represent the mathematical concept of infinity.

  

Float(infinity) can be returned by a function or an operation when the input operands are such that the indicated function or operation will overflow (that is, produce a value that cannot be represented in the Floata,b format).

  

Float(infinity) can be either or both components of a complex number (for example, Float(infinity) + 3.7*I, 0. + Float(infinity)*I).  By convention, Maple treats all complex numbers both of whose components are Float(infinity) as the single point complex infinity.  This is a convention only, but you (and in your programs) should be cautious about relying on the sign of the real or imaginary part of such an object. See type/cx_infinity.

Notes regarding undefined

  

The quantity Float(undefined) represents a non-numeric object in the floating-point system.  This value can be returned by a function or operation if the input operands are not in the domain of the function or operand.

  

Note: Float(undefined) values always compare as equal. You can also use type(expr, undefined) to check for an undefined value.

  

You can tag a Float(undefined) object with the notation Float(n,undefined), where n is a non-zero integer.  Whenever possible, Maple preserves this object, in the sense that if it is passed in as an operand to a function or operation, Maple tries to return the same value if it makes sense to do so.  In this way, it is possible to perform some retrospective analysis to determine precisely when the object first appeared.

  

Float(undefined) can be either or both components of a complex number (for example, Float(undefined) + 1.*I, Float(infinity) + Float(undefined)*I. The type undefined recognizes such an object.

Notes regarding zero

  

In its floating-point format, 0 has a sign. The sign of 0 is preserved by arithmetic operations whenever possible, according to the standard rules of algebra. Operations and functions can use the sign of 0 to distinguish qualitative information (for example, branch cut closure), but not quantitative information (-0.0 < +0.0 returns false).

  

It is possible that the result of a computation is mathematically 0, but the sign of that result cannot be established from the application of the standard rules of arithmetic. The simplest such example is x - x.  In such cases, Maple uses the following convention.

  

The result of an indefinitely signed computation whose mathematical value is '0' is set to '+0', unless the `rounding` mode is set to '-infinity', in which case it is set to '-0'.

  

This convention is implemented by the Default0 function.

  

Corresponding to the convention regarding complex infinities, as described above, Maple treats all complex numbers, both of whose components are floating-point 0.'s, as the same.  Again, this is a convention, but code should in general not rely on the sign of the real or imaginary part of 0.&plus;0.I, 0.0.I, etc.

• 

The Float constructor is called during parsing of all floating-point numbers and so can be overloaded by creating a module like this: M := module() export Float; Float := proc(m,e) m*ten^e; end; end; The statement, use M in 1.234 end; will then return 123*ten^(-2);

Examples

The Float command will only be seen when this page is viewed in 1-D Math.

2.3

2.3

(1)

2.

2.

(2)

0.3

0.3

(3)

x23000.

x:=23000.

(4)

1.2106x

2.761010

(5)

Default0

0.

(6)

Rounding&infin;

Rounding:=&infin;

(7)

2.2.

0.

(8)

Default0

0.

(9)

2.310-44

2.310-44

(10)

SFloat23&comma;45

2.310-44

(11)

0.002

0.002

(12)

interfaceprettyprint&equals;0

1

(13)

2.3

2.3

(14)

y23000.

y:=23000.

(15)

1.2105y

2.76109

(16)

2.310-44

2.310-44

(17)

Here is an example of float overflow:

&ExponentialE;1.10100

Float&infin;

(18)

See Also

constant

convert

Default0

Digits

evalf

HFloat

integer

op

type

type/cx_infinity

type/float

type/hfloat

type/numeric

type/sfloat

UseHardwareFloats

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam