convert/rational - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Conversion : convert/rational

convert/rational

convert float to an approximate rational

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

convert(float, rational, digits)

convert(float, fraction, digits)

Parameters

float

-

floating-point number

digits

-

(optional) integer or the name exact

Description

• 

The convert/rational function converts a floating-point number to an approximate rational number. The meaning of the type fraction is identical with rational in this context.

• 

The accuracy of the conversion will depend on the value of the global variable Digits, or the value of digits if specified as an integer.

• 

If the third argument digits is the name 'exact' then an exact conversion of float to a rational will be performed; thus Float(f, e) becomes simply f*10^e. Note that exact conversion executes much more quickly than the more sophisticated conversion.

  

Note: See also the identify command to find a closed form for a decimal approximation of a number.

Examples

convert0.125,rational

18

(1)

convert2.345,rational

469200

(2)

convert0.3333333333,rational

13

(3)

convert0.3333333333,rational,exact

333333333310000000000

(4)

convertevalfπ,rational

10434833215

(5)

convertevalfπ,rational,3

227

(6)

convertevalfπ,rational,exact

1570796327500000000

(7)

See Also

convert

Digits