summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/manual.txt63
-rwxr-xr-xdoc/nimrodc.txt12
2 files changed, 60 insertions, 15 deletions
diff --git a/doc/manual.txt b/doc/manual.txt
index 8399dc4b0..391f319a1 100755
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -47,7 +47,7 @@ components called `locations`:idx:. A variable is basically a name for a
 location. Each variable and location is of a certain `type`:idx:. The
 variable's type is called `static type`:idx:, the location's type is called
 `dynamic type`:idx:. If the static type is not the same as the dynamic type,
-it is a supertype or subtype of the dynamic type.
+it is a super-type or subtype of the dynamic type.
 
 An `identifier`:idx: is a symbol declared as a name for a variable, type,
 procedure, etc. The region of the program over which a declaration applies is
@@ -424,8 +424,8 @@ Integers, bool, characters and enumeration types (and subrange of these
 types) belong to ordinal types.
 
 
-Pre-defined numerical types
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Pre-defined integer types
+~~~~~~~~~~~~~~~~~~~~~~~~~
 These integer types are pre-defined:
 
 ``int``
@@ -469,6 +469,14 @@ operation                meaning
                          ``int32`` type)
 ======================   ======================================================
 
+`Automatic type conversion`:idx: is performed in expressions where different
+kinds of integer types are used: the smaller type is converted to the larger.
+For further details, see `Convertible relation`_.
+
+
+Pre-defined floating point types
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 The following floating point types are pre-defined:
 
 ``float``
@@ -482,16 +490,49 @@ floatXX
   implementation supports ``float32`` and ``float64``. Literals of these types
   have the suffix 'fXX.
 
-`Automatic type conversion`:idx: is performed in expressions where different
-kinds of integer types are used. However, if the type conversion
-loses information, the `EOutOfRange`:idx: exception is raised (if the error
-cannot be detected at compile time).
 
 Automatic type conversion in expressions with different kinds
-of floating point types is performed: the smaller type is
-converted to the larger. Arithmetic performed on floating point types
-follows the IEEE standard. Integer types are not converted to floating point
-types automatically and vice versa.
+of floating point types is performed: See `Convertible relation`_ for further
+details. Arithmetic performed on floating point types follows the IEEE
+standard. Integer types are not converted to floating point types automatically
+and vice versa.
+
+The IEEE standard defines five types of floating-point exceptions:
+
+* Invalid: operations with mathematically invalid operands,
+  for example 0.0/0.0, sqrt(-1.0), and log(-37.8).
+* Division by zero: divisor is zero and dividend is a finite nonzero number,
+  for example 1.0/0.0.
+* Overflow: operation produces a result that exceeds the range of the exponent, 
+  for example MAXDOUBLE+0.0000000000001e308.
+* Underflow: operation produces a result that is too small to be represented 
+  as a normal number, for example, MINDOUBLE * MINDOUBLE.
+* Inexact: operation produces a result that cannot be represented with infinite 
+  precision, for example, 2.0 / 3.0, log(1.1) and 0.1 in input.
+
+The IEEE exceptions are either ignored at runtime or mapped to the 
+Nimrod exceptions: `EFloatInvalidOp`:idx, `EFloatDivByZero`:idx:,
+`EFloatOverflow`:idx:, `EFloatUnderflow`:idx:, and `EFloatInexact`:idx:\. 
+These exceptions inherit from the `EFloatingPoint`:idx: base class.
+
+Nimrod provides the pragmas `NaNChecks`:idx and `InfChecks`:idx:\ to control
+whether the IEEE exceptions are ignored or trap a Nimrod exception:
+
+.. code-block:: nimrod
+  {.NanChecks: on, InfChecks: on.}
+  var a = 1.0
+  var b = 0.0
+  echo b / b # raises EFloatInvalidOp
+  echo a / b # raises EFloatOverflow
+
+In the current implementation ``EFloatDivByZero`` and ``EFloatInexact`` are 
+never raised. ``EFloatOverflow`` is raised instead of ``EFloatDivByZero``.
+There is also a `floatChecks`:idx: pragma that is a short-cut for the 
+combination of ``NaNChecks`` and ``InfChecks`` pragmas. ``floatChecks`` are
+turned off as default.
+
+The only operations that are affected by the ``floatChecks`` pragma are
+the ``+``, ``-``, ``*``, ``/`` operators for floating point types.
 
 
 Boolean type
diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt
index a7c84a0ec..4a94bc8cf 100755
--- a/doc/nimrodc.txt
+++ b/doc/nimrodc.txt
@@ -7,6 +7,10 @@
 
 .. contents::
 
+  "Look at you, hacker. A pathetic creature of meat and bone, panting and
+  sweating as you run through my corridors. How can you challenge a perfect,
+  immortal machine?"
+
 
 Introduction
 ============
@@ -242,7 +246,7 @@ memory, but nothing worse happens.
 
 
 DeadCodeElim Pragma
-~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~
 The `deadCodeElim`:idx: pragma only applies to whole modules: It tells the
 compiler to activate (or deactivate) dead code elimination for the module the
 pragma appers in.
@@ -304,13 +308,13 @@ Optimizing string handling
 String assignments are sometimes expensive in Nimrod: They are required to
 copy the whole string. However, the compiler is often smart enough to not copy
 strings. Due to the argument passing semantics, strings are never copied when
-passed to subroutines. The compiler does not copy strings that are result from
-a procedure call, because the called procedure returns a new string anyway.
+passed to subroutines. The compiler does not copy strings that are a result from
+a procedure call, because the callee returns a new string anyway.
 Thus it is efficient to do:
 
 .. code-block:: Nimrod
   var s = procA() # assignment will not copy the string; procA allocates a new
-                  # string anyway
+                  # string already
 
 However it is not efficient to do: