Difference between revisions of "CoCoA:DecimalStr"

From ApCoCoAWiki
(pushing XML rev. 1.46, again)
 
(No difference)

Latest revision as of 10:02, 24 October 2007

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>