# cf.rtol¶

cf.rtol(*arg)[source]

The numerical equality tolerance on relative differences.

Two real numbers x and y are considered equal if |x-y|<=atol+rtol|y|, where atol (the tolerance on absolute differences) and rtol (the tolerance on relative differences) are positive, typically very small numbers. The values of atol and rtol are initialised to the system epsilon (the difference between 1 and the least value greater than 1 that is representable as a float).

New in version (cfdm): 1.7.0

Parameters
arg: float or Constant, optional

The new value of relative tolerance. The default is to not change the current value.

Returns
Constant

The value prior to the change, or the current value if no new value was specified.

Examples:

>>> cf.rtol()
<CF Constant: 2.220446049250313e-16>
>>> print(cf.rtol())
2.220446049250313e-16
>>> str(cf.rtol())
'2.220446049250313e-16'
>>> cf.rtol().value
2.220446049250313e-16
>>> float(cf.rtol())
2.220446049250313e-16

>>> old = cf.rtol(1e-10)
>>> cf.rtol()
<CF Constant: 2.220446049250313e-16>
>>> cf.rtol(old)
<CF Constant: 1e-10>
>>> cf.rtol()
<CF Constant: 2.220446049250313e-16>


Use as a context manager:

>>> print(cf.rtol())
2.220446049250313e-16
>>> with cf.rtol(1e-5):
...     print(cf.rtol(), cf.rtol(2e-30), cf.rtol())
...
1e-05 1e-05 2e-30
>>> print(cf.rtol())
2.220446049250313e-16