# SETMATHERR()

Sets the math error correction status and mode

Syntax

  SETMATHERR ([<nStatus>] [,<[@]nMode>]) -> nOldStatus

Arguments

  [<nStatus>] new math error correction status [<[@]nMode>] new math error correction mode OR placeholder for current mode (if passed by reference)

Returns

  nOldStatus old (if nStatus is a valid value, see below) or current mode of math error correction

Description

  Most math functions within the CT3 library (and in Harbour itself) rely on the standard C math library which, on some platforms, calls a certain, user-definable error handling routine when one of the following mathematical errors occur (constants defined in cterror.ch):
  CT_ERROR_MATHLIB unknown math lib error CT_ERROR_MATHLIB_DOMAIN a domain error has occured, such as sqrt (-1) CT_ERROR_MATHLIB_SING a singularity will result, such as pow (0, -2) CT_ERROR_MATHLIB_OVERFLOW an overflow will result, such as pow (10, 100) CT_ERROR_MATHLIB_UNDERFLOW an underflow will result, such as pow (10, -100) CT_ERROR_MATHLIB_TLOSS total loss of significance will result, such as exp (1000) CT_ERROR_MATHLIB_PLOSS partial loss of significance will result, such as sin (10e70)
  The CT3 library redirects these errors within its math routines to its own math handler. The behaviour of this handler depends on the values of <nStatus> and <nMode>:
  The values of <nStatus> and <nOldStatus> specify whether the CT3 math handler is active. It can be one of the following values (defined in ct.ch):
  CT_MATHERR_STATUS_NOTFOUND math handler is not installed CT_MATHERR_STATUS_INACTIVE math handler is installed but inactive CT_MATHERR_STATUS_ACTIVE math handler is installed and active
  Be aware that, if CT_MATHERR_STATUS_NOTFOUND is used as argument, SETMATHERR() will NOT deinstall the math handler. The math handler is installed by CTINIT(), remains inactive at first, and is deinstalled by CTEXIT().
  The value of <nMode> specifies the behaviour of the CT3 math handler if it is installed and active. It can be one of the following values:
  CT_MATHERR_MODE_NONE no correction at all, program will exit CT_MATHERR_MODE_DEFAULT default return value will be used, no error msgs ! CT_MATHERR_MODE_USER error will be thrown to user who is responsible for error correction CT_MATHERR_MODE_USERDEFAULT error will be thrown, but if user fails, default correction will be used
  The default behaviour is CT_MATHERR_MODE_DEFAULT.
  Be aware that, if <nMode> is passed by reference, SETMATHERR() will store the current value in <@nMode> rather than setting a new one.

Status

  Ready

Compliance

  SETMATHERR() is a new function in Harbour's CT3 library.

Platforms

  All

Files

  Source is ctmath.c, library is ct3.

See Also

- CTINIT() CTEXIT()