Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.77.0/docs/_sources/number_0.rst.txt

.. index:: number .. _number/0:

.. rst-class:: right

object

number

Number data type predicates.

| Availability: | logtalk_load(types(loader))

| Author: Paulo Moura | Version: 1:14:0 | Date: 2023-12-07

| Compilation flags: | static, context_switching_calls

| Extends: | public :ref:`atomic <atomic/0>`

| Remarks: | (none)

| Inherited public predicates: |  :ref:`comparingp/0::(<)/2`  :ref:`comparingp/0::(=:=)/2`  :ref:`comparingp/0::(=<)/2`  :ref:`comparingp/0::(=\=)/2`  :ref:`comparingp/0::(>)/2`  :ref:`comparingp/0::(>=)/2`  :ref:`termp/0::check/1`  :ref:`termp/0::depth/2`  :ref:`termp/0::ground/1`  :ref:`termp/0::new/1`  :ref:`termp/0::numbervars/1`  :ref:`termp/0::numbervars/3`  :ref:`termp/0::occurs/2`  :ref:`termp/0::singletons/2`  :ref:`termp/0::subsumes/2`  :ref:`termp/0::subterm/2`  :ref:`termp/0::valid/1`  :ref:`termp/0::variables/2`  :ref:`termp/0::variant/2`  :ref:`termp/0::varnumbers/2`  :ref:`termp/0::varnumbers/3`  

.. contents:: :local: :backlinks: top

Public predicates

.. index:: approximately_equal/2 .. _number/0::approximately_equal/2:

approximately_equal/2 ^^^^^^^^^^^^^^^^^^^^^^^^^

Compares two numbers for approximate equality given the epsilon arithmetic constant value using the de facto standard formula abs(Number1 - Number2) =< max(abs(Number1), abs(Number2)) * epsilon. No type-checking.

| Compilation flags: | static

| Template: | approximately_equal(Number1,Number2) | Mode and number of proofs: | approximately_equal(+number,+number) - zero_or_one


.. index:: approximately_equal/3 .. _number/0::approximately_equal/3:

approximately_equal/3 ^^^^^^^^^^^^^^^^^^^^^^^^^

Compares two numbers for approximate equality given a user-defined epsilon value using the de facto standard formula abs(Number1 - Number2) =< max(abs(Number1), abs(Number2)) * Epsilon. No type-checking.

| Compilation flags: | static

| Template: | approximately_equal(Number1,Number2,Epsilon) | Mode and number of proofs: | approximately_equal(+number,+number,+number) - zero_or_one

| Remarks:

  • Epsilon range: Epsilon should be the epsilon arithmetic constant value or a small multiple of it. Only use a larger value if a greater error is expected.
  • Comparison with essential equality: For the same epsilon value, approximate equality is weaker requirement than essential equality.

.. index:: essentially_equal/3 .. _number/0::essentially_equal/3:

essentially_equal/3 ^^^^^^^^^^^^^^^^^^^^^^^

Compares two numbers for essential equality given an epsilon value using the de facto standard formula abs(Number1 - Number2) =< min(abs(Number1), abs(Number2)) * Epsilon. No type-checking.

| Compilation flags: | static

| Template: | essentially_equal(Number1,Number2,Epsilon) | Mode and number of proofs: | essentially_equal(+number,+number,+number) - zero_or_one

| Remarks:

  • Comparison with approximate equality: For the same epsilon value, essential equality is a stronger requirement than approximate equality.

.. index:: tolerance_equal/4 .. _number/0::tolerance_equal/4:

tolerance_equal/4 ^^^^^^^^^^^^^^^^^^^^^

Compares two numbers for close equality given relative and absolute tolerances using the de facto standard formula abs(Number1 - Number2) =< max(RelativeTolerance * max(abs(Number1), abs(Number2)), AbsoluteTolerance). No type-checking.

| Compilation flags: | static

| Template: | tolerance_equal(Number1,Number2,RelativeTolerance,AbsoluteTolerance) | Mode and number of proofs: | tolerance_equal(+number,+number,+number,+number) - zero_or_one


.. index:: =~= / 2 .. _number/0::=~= / 2:

=~= / 2 ^^^^^^^^^^^

Compares two floats (or lists of floats) for approximate equality using 100*epsilon for the absolute error and, if that fails, 99.999% accuracy for the relative error. Note that these precision values may not be adequate for all cases. No type-checking.

| Compilation flags: | static

| Template: | =~=(Float1,Float2) | Mode and number of proofs: | =~=(+number,+number) - zero_or_one | =~=(+list(number),+list(number)) - zero_or_one


Protected predicates

(no local declarations; see entity ancestors if any)

Private predicates

(no local declarations; see entity ancestors if any)

Operators

op(700,xfx,=~=) ^^^^^^^^^^^^^^^^^^^

| Scope: | public