Difference between revisions of "ApCoCoA-1:Dec"

From ApCoCoAWiki
Line 15: Line 15:
 
<item>@return The given object with floating point numbers represented as strings instead of (rational) numbers.</item>
 
<item>@return The given object with floating point numbers represented as strings instead of (rational) numbers.</item>
 
</itemize>
 
</itemize>
 +
 +
<example>
 +
Use P::=Q[x,y,z];
 +
 +
Dec(1,4);
 +
1
 +
-------------------------------
 +
Dec(1/2,4);
 +
0.5
 +
-------------------------------
 +
A:=Mat([[17/13, 6/11], [5/3, 1/9]]);
 +
Dec(A,4);
 +
Mat([
 +
  ["1.3076", "0.5454"],
 +
  ["1.6666", "0.1111"]
 +
])
 +
-------------------------------
 +
</example>
 +
 
</description>
 
</description>
  
Line 26: Line 45:
  
 
<seealso>
 
<seealso>
  <see>Print<see>
+
  <see>Print</see>
  <see>Print On<see>
+
  <see>Print On</see>
  <see>PrintLn<see>
+
  <see>PrintLn</see>
 
</seealso>
 
</seealso>
  

Revision as of 15:34, 24 April 2009

Dec

Pretty Printing of Objects.

Syntax

Dec(X:Object, Digits:INT):Object

Description

This function prints (rational) numbers within the object X as a floating point number up to Digits Digits. The floating point numbers are represented as strings.

  • @param X The object whose numbers should be printed as floating points. X can be MAT, LIST, POLY, INT, RAT or iteration thereof.

  • @param Digits Gives the exactness of printing.

  • @return The given object with floating point numbers represented as strings instead of (rational) numbers.

Example

Use P::=Q[x,y,z];

Dec(1,4);
1
-------------------------------
Dec(1/2,4);
0.5
-------------------------------
A:=Mat([[17/13, 6/11], [5/3, 1/9]]);
Dec(A,4);
Mat([
  ["1.3076", "0.5454"],
  ["1.6666", "0.1111"]
])
-------------------------------



See also

Print

Print On

PrintLn