From OpenCog
(Redirected from Number)

The NumberNode is a type of Node that holds double-precision floating point numbers. It is typically used in arithmetical operations, such as PlusLink and TimesLink. For example, the following scheme expression

      (NumberNode 2)
         (NumberNode 3)
         (NumberNode 4))))

will yield

 (NumberNode "14.000000")

as a result. NumberNodes can be compared with the EqualLink and the GreaterThanLink. So for example,

     NumberNode 42
          NumberNode 2
          NumberNode 2

will evaluate to "true" when evaluated by the pattern matcher or by cog-evaluate!.

NumberNodes can hold a vector (list) of numbers, as well. Thus

 NumberNode 1 2 3 4 5

is valid. The arithmetic operations work correctly on such vectors; so for example

      (NumberNode 2 3 20 50)
      (NumberNode 2 5 10 80))))

will return (NumberNode 4 8 30 130), as might be expected. (The GreaterThanLink is not currently defined on vectors; the current implementation only examines the first element of the vector.)


The Value subsystem provides a superior mechanism for storing, recording, and working with fleeting and time-changing data. There are multiple problems with using Atoms for transient data, including: (a) it is CPU-intensive to create an Atom. Creating Values is much faster. (b) it is CPU-intensive to insert an Atom into the AtomSpace. Values are not stored in the atomsapce. For fleeting data, there is almost never any functional need for the indexing services that the AtomSpace provides, so its pointless to store fleeting data there, anyway. (c) it can become very difficult, sometimes impossible, to remove Atoms from the atomspace. This can happen when an Atom become a part of the outgoing set of another atom; in such a case, it would be illegal to delete the atom. For these three reasons, Values provide a superior mechanism for storing and working with fleeting numerical data. They just work better.

In other words, if you think that you need NumberNodes, its very likely that you don't, and that you would be better off working with Values instead.

See also