]> www.ginac.de Git - ginac.git/commitdiff
[DOC] Additional examples on number conversions.
authorVladimir V. Kisil <kisilv@maths.leeds.ac.uk>
Sun, 9 Jun 2019 16:40:58 +0000 (18:40 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Sun, 9 Jun 2019 16:40:58 +0000 (18:40 +0200)
Some aspects of these methods are not obvious for newbies.

Signed-off-by: Vladimir V. Kisil <kisilv@maths.leeds.ac.uk>
doc/tutorial/ginac.texi

index bc4b87fc0a65eca8b8290782f4bb8e33a7de5bec..a34595850841d5359a3bd1f1e3090ae046dd9862 100644 (file)
@@ -1533,6 +1533,15 @@ rational number will return a floating-point approximation. Both
 @code{to_int()/to_long()} and @code{to_double()} discard the imaginary
 part of complex numbers.
 
 @code{to_int()/to_long()} and @code{to_double()} discard the imaginary
 part of complex numbers.
 
+Note the signature of the above methods, you may need to apply a type
+conversion and call @code{evalf()} as shown in the following example:
+@example
+    ...
+    ex e1 = 1, e2 = sin(Pi/5);
+    cout << ex_to<numeric>(e1).to_int() << endl
+         << ex_to<numeric>(e2.evalf()).to_double() << endl;
+    ...
+@end example
 
 @node Constants, Fundamental containers, Numbers, Basic concepts
 @c    node-name, next, previous, up
 
 @node Constants, Fundamental containers, Numbers, Basic concepts
 @c    node-name, next, previous, up