triggers a numeric event
NumericEvent(event, operation, operands, default_value)
symbol that represents one of six numeric events
name of the operation causing the event
list of the operands to that operation
suggested default value for the event handler to return
A numeric event is an indication of an anomalous numerical computation. Six types of anomalies are detected by Maple:
An invalid computation was attempted, such as ∞ - ∞
An infinite singularity occurred, such as 1/0 or ln(0)
The result of a computation is too large to represent
The result of a computation is too small to represent
The result of a computation is not exactly representable
An operation with all real operands returned a complex (non-real) result
When a numeric event is signaled, its corresponding event handler is invoked to determine what should happen next. Maple has default handlers for each of the 6 numeric events. You can install your own event handler by using the NumericEventHandler routine.
In addition to the automatic triggering of events by built-in numeric operations, user code can trigger an event explicitly by calling the NumericEvent function.
The event parameter specifies which event is to be triggered, and is specified by one of the event symbols listed above.
The optional operation and operands parameters are the values that will be passed as the operation and operands parameters to the event handler (see NumericEventHandler). If NumericEvent is called from within a Maple function, these parameters can be omitted, and the values procname and [args] will be passed in their place.
The default_value parameter indicates a suggested default value. For example, a handler for division_by_zero might be passed a default_value of infinity or -infinity, depending on the sign of the dividend.
If the event handler returns a result, NumericEvent will return that result. If the event handler raises an exception, NumericEvent will not return to the point it was called.
The NumericStatus function can be used to determine which numeric events have been signaled during a computation.
Numeric events are signaled for operations involving hardware floating-point numbers, arbitrary precision software floating-point numbers, and exact numbers in the regular Maple computation environment. However, in the evalhf environment, in Compiled code, and in code generated for other environments by the CodeGeneration package, non-default numeric event handling settings are not guaranteed to be respected.
MyDivide := proc(a,b)
if b = 0 then
if a < 0 then NumericEvent(division_by_zero,-1e10000)
a / b
Error, (in MyDivide) numeric exception: division by zero
MyHandler := proc(operator,operands,default_value)
# MyHandler issues a warning, clears the status flag and then
# continues with the default value.
WARNING("division by zero in %1 with args %2",operator,operands);
NumericStatus(division_by_zero = false);
Warning, division by zero in MyDivide with args [-3.0, 0.]
Download Help Document
What kind of issue would you like to report? (Optional)