- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- How to Turn Off Floating-Point Exception Interrupt...
Operating System - OpenVMS
1821801
Members
3060
Online
109637
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2006 03:09 AM
тАО01-09-2006 03:09 AM
If I have overflowed floating-point values in my C program, the program is interrupted and floating-point value exception message is returned by default. Is there any way to turn off this exception handling, like a compiler option or system function?
I'm running on a OpenVMS Alpha system. I mainly care about VAX floating-point types. I've tried cc option /PDSC_MASK=SILENT but saw no difference. I believe there's no such systerm functions as feholdexcept() on Unix to turn off exception complaint. My short test program is attached below.
Thanks for helping me.
Ray
------------------
#include
#include
int main(void)
{
int i, j;
double d;
unsigned char *dp = (unsigned char*)&d;
float f;
for (i=0; i<16; i++) {
for (j=0; j dp[j] = rand();
f = (float)d;
printf("f=%g\n", (float)f);
}
return 0;
}
I'm running on a OpenVMS Alpha system. I mainly care about VAX floating-point types. I've tried cc option /PDSC_MASK=SILENT but saw no difference. I believe there's no such systerm functions as feholdexcept() on Unix to turn off exception complaint. My short test program is attached below.
Thanks for helping me.
Ray
------------------
#include
#include
int main(void)
{
int i, j;
double d;
unsigned char *dp = (unsigned char*)&d;
float f;
for (i=0; i<16; i++) {
for (j=0; j
f = (float)d;
printf("f=%g\n", (float)f);
}
return 0;
}
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2006 07:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2006 07:59 AM
тАО01-09-2006 07:59 AM
Re: How to Turn Off Floating-Point Exception Interruption
Ray,
It's very dangerous to ignore fatal exceptions. However, if you really want to you can catch any exception using an exception handler and then do what you like with it.
Here's an example based on your sample program using the standard handler LIB$SIG_TO_RET which converts any signalled exception into a return status and unwinds from the declaring routine.
#include
#include
#include
int sub(float *f){
int i, j;
double d;
unsigned char *dp = (unsigned char*)&d;
VAXC$ESTABLISH(LIB$SIG_TO_RET);
for (i=0; i<16; i++) {
for (j=0; j dp[j] = rand();
*f = (float)d;
}
return 1;
}
int main(void)
{
float f;
printf("stat=%d f=%g \n", sub(&f),(float)f);
return 0;
}
The result is
stat=1284 f=0
1284 is HPARITH, and f is 0 because the store operation that resulted in the exception did not complete. By the time you're back in the main program, all the useful information from the signal array and mechanism args has been lost.
If you want different behaviour you can write your own exception handler, but I'm not sure if you'll be able to continue from a fatal exception, so unwinding may be your only option.
It's very dangerous to ignore fatal exceptions. However, if you really want to you can catch any exception using an exception handler and then do what you like with it.
Here's an example based on your sample program using the standard handler LIB$SIG_TO_RET which converts any signalled exception into a return status and unwinds from the declaring routine.
#include
#include
#include
int sub(float *f){
int i, j;
double d;
unsigned char *dp = (unsigned char*)&d;
VAXC$ESTABLISH(LIB$SIG_TO_RET);
for (i=0; i<16; i++) {
for (j=0; j
*f = (float)d;
}
return 1;
}
int main(void)
{
float f;
printf("stat=%d f=%g \n", sub(&f),(float)f);
return 0;
}
The result is
stat=1284 f=0
1284 is HPARITH, and f is 0 because the store operation that resulted in the exception did not complete. By the time you're back in the main program, all the useful information from the signal array and mechanism args has been lost.
If you want different behaviour you can write your own exception handler, but I'm not sure if you'll be able to continue from a fatal exception, so unwinding may be your only option.
A crucible of informative mistakes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2006 08:19 AM
тАО01-09-2006 08:19 AM
Re: How to Turn Off Floating-Point Exception Interruption
Perhaps sigaction()...
#include
#include
#include
int main(void)
{
int i, j;
double d;
unsigned char *dp = (unsigned char*)&d;
float f;
struct sigaction ignore;
ignore.sa_handler = SIG_IGN;
ignore.sa_flags = 0;
sigemptyset(&ignore.sa_mask);
sigaction(SIGFPE,&ignore,(struct sigaction *)NULL);
for (i=0; i<16; i++) {
for (j=0; j dp[j] = rand();
f = (float)d;
printf("f=%g\n", (float)f);
}
return 0;
}
#include
#include
#include
int main(void)
{
int i, j;
double d;
unsigned char *dp = (unsigned char*)&d;
float f;
struct sigaction ignore;
ignore.sa_handler = SIG_IGN;
ignore.sa_flags = 0;
sigemptyset(&ignore.sa_mask);
sigaction(SIGFPE,&ignore,(struct sigaction *)NULL);
for (i=0; i<16; i++) {
for (j=0; j
f = (float)d;
printf("f=%g\n", (float)f);
}
return 0;
}
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP