CoCoA:DecimalStr

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

DecimalStr

convert rational number to decimal string

Description

This function computes a decimal approximation with NumDigits

decimal digits of a rational number (default value is 3) and converts

it into a string for printing. If the returned string presents less than NumDigits decimal digits, then the string represents the exact value of the input.

Example

  DecimalStr(1/3);
0.333
-------------------------------
  DecimalStr(1/3, 60);
0.333333333333333333333333333333333333333333333333333333333333
-------------------------------
  DecimalStr(121/10);
12.1
-------------------------------

Syntax

DecimalStr(X:RAT):STRING
DecimalStr(X:RAT, NumDigits:INT):STRING

FloatStr

MantissaAndExponent

   <type>rat</type>
   <type>string</type>