event-symbol that represents one of six numeric eventsoperation-name of the operation causing the eventoperands-list of the operands to that operationdefault_value-suggested default value for the event handler to return

<Text-field style="Heading 2" layout="Heading 2" bookmark="info">Description</Text-field>A numeric event is an indication of an anomalous numerical computation. Six types of anomalies are detected by Maple: invalid_operationAn invalid computation was attempted, such as NiMtSSNtaUc2JEkqcHJvdGVjdGVkR0YmL0krbW9kdWxlbmFtZUc2IkksVHlwZXNldHRpbmdHNiRGJkkoX3N5c2xpYkdGKTYjUSgmaW5maW47Rik= - NiMtSSNtaUc2JEkqcHJvdGVjdGVkR0YmL0krbW9kdWxlbmFtZUc2IkksVHlwZXNldHRpbmdHNiRGJkkoX3N5c2xpYkdGKTYjUSgmaW5maW47Rik=division_by_zeroAn infinite singularity occurred, such as 1/0 or ln(0)overflowThe result of a computation is too large to representunderflowThe result of a computation is too small to representinexactThe result of a computation is not exactly representablereal_to_complexAn 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.
<Text-field style="Heading 2" layout="Heading 2" bookmark="examples">Examples</Text-field>MyDivide := proc(a,b)
if b = 0 then
if a < 0 then NumericEvent(division_by_zero,-1e10000)
else NumericEvent(division_by_zero,1e10000)
end if
else
a / b
end if
end proc:MyDivide(3.0,0.0);NumericEventHandler(division_by_zero=exception):MyDivide(3.0,0.0);NumericStatus(division_by_zero = false);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);
default_value;
end proc:NumericEventHandler(division_by_zero=MyHandler):MyDivide(-3.0,0.0);NumericStatus(division_by_zero = false);See AlsoerrorNumericEventHandlerNumericStatustry