Standard_Underflow
The `Standard_Underflow` diagnostic is a C++ exception in Open CASCADE Technology (OCCT) raised when a floating-point calculation evaluates to a subnormal value. It typically occurs when hardware floating-point exceptions (FPE) are enabled globally via `OSD::SetSignal()` and caught using the `OCC_CATCH_SIGNALS` macro.
In Open CASCADE Technology, `Standard_Underflow` is an exception class that inherits from `Standard_NumericError`. It represents a numeric fault where an arithmetic operation produces a result whose absolute value is too small to be represented as a normalized floating-point number. By default on most modern architectures and operating systems, floating-point underflows do not trigger hardware traps; they silently evaluate to subnormal values or zero. However, when an application explicitly enables hardware-level floating-point traps (e.g., for strict numeric debugging), the operating system will issue a SIGFPE signal upon an underflow event. OCCT captures this signal and converts it into a C++ `Standard_Underflow` exception, allowing it to be safely handled through OCCT's macro-wrapped `try`-`catch` block utilizing `OCC_CATCH_SIGNALS`.
This diagnostic is emitted because floating-point exceptions (FPE) have been globally enabled in the application, and a mathematical operation in OCCT's geometry or topology algorithms resulted in a floating-point underflow. When `OSD::SetSignal()` is called to configure signal handlers, OCCT configures the process to trap numeric faults. Upon encountering an underflow, OCCT's error handler intercepts the resulting hardware signal and translates it to a `Standard_Underflow` C++ exception. Additionally, it can be emitted manually if a predefined threshold condition in the `Standard_Underflow_Raise_if` macro evaluates to true.
#include <OSD.hxx>
#include <Standard_Underflow.hxx>
#include <Standard_ErrorHandler.hxx>
#include <iostream>
int main() {
// Enable floating-point exceptions, instructing OCCT to convert OS signals into C++ exceptions
OSD::SetSignal(Standard_True);
try {
OCC_CATCH_SIGNALS
// Explicitly raise the exception, simulating an enabled FPE trap hitting an underflow condition
Standard_Underflow_Raise_if(true, "Simulated mathematical underflow");
} catch (const Standard_Underflow& e) {
std::cerr << "Caught Standard_Underflow: " << e.GetMessageString() << std::endl;
return 1;
}
return 0;
}
Disable floating-point exceptions to permit silent underflow evaluations, or isolate volatile geometric code blocks with `OCC_CATCH_SIGNALS` to catch and manage the exact exception.
```C++
#include <OSD.hxx>
#include <Standard_Underflow.hxx>
#include <Standard_ErrorHandler.hxx>
#include <iostream>
int main() {
// Disable hardware floating-point traps by passing Standard_False.
// This permits math underflows to silently evaluate to zero or subnormal values as per IEEE-754.
OSD::SetSignal(Standard_False);
try {
OCC_CATCH_SIGNALS
// Simulated numeric operation - underflow trap is bypassed or exception evaluates harmlessly
Standard_Underflow_Raise_if(false, "Underflow gracefully suppressed");
std::cout << "Calculations completed successfully without termination." << std::endl;
} catch (const Standard_Underflow& e) {
// Fallback logic if the exception was legitimately raised
std::cerr << "Handled Standard_Underflow: " << e.GetMessageString() << std::endl;
return 1;
}
return 0;
}
```
Open CASCADE Technology OCCT 7.8.0 — Standard_Underflow.hxx — retrieved 2026-08-11