From: Vladimir V. Kisil Date: Sun, 9 Jun 2019 16:40:58 +0000 (+0200) Subject: [DOC] Additional examples on number conversions. X-Git-Tag: release_1-7-7~8 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=6def7b34955b8ed51e20ccca7d3d702bc2e9dca4 [DOC] Additional examples on number conversions. Some aspects of these methods are not obvious for newbies. Signed-off-by: Vladimir V. Kisil --- diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index bc4b87fc..a3459585 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -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. +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(e1).to_int() << endl + << ex_to(e2.evalf()).to_double() << endl; + ... +@end example @node Constants, Fundamental containers, Numbers, Basic concepts @c node-name, next, previous, up