summaryrefslogtreecommitdiff
path: root/doc/syntax
diff options
context:
space:
mode:
Diffstat (limited to 'doc/syntax')
-rw-r--r--doc/syntax/literals.rdoc27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc
index b8ed7f7c54..62b80db04b 100644
--- a/doc/syntax/literals.rdoc
+++ b/doc/syntax/literals.rdoc
@@ -71,6 +71,33 @@ Examples:
All these numbers have the same decimal value, 170. Like integers and floats
you may use an underscore for readability.
+=== Rational numbers
+
+Numbers suffixed by +r+ are Rational numbers.
+
+ 12r #=> (12/1)
+ 12.3r #=> (123/10)
+
+Rational numbers are exact, whereas Float numbers are inexact.
+
+ 0.1r + 0.2r #=> (3/10)
+ 0.1 + 0.2 #=> 0.30000000000000004
+
+=== Complex numbers
+
+Numbers suffixed by +i+ are Complex (or imaginary) numbers.
+
+ 1i #=> (0+1i)
+ 1i * 1i #=> (-1+0i)
+
+Also Rational numbers may be imaginary numbers.
+
+ 12.3ri #=> (0+(123/10)*i)
+
++i+ must be placed after +r+, the opposite is not allowed.
+
+ 12.3ir #=> syntax error
+
== Strings
The most common way of writing strings is using <tt>"</tt>: