floating point exception

This is a discussion on floating point exception within the C Programming forums, part of the General Programming Boards category; Hi! Can someone tell me how to handle floating point exceptions in C.I am working on a linux platform....

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    24

    floating point exception

    Hi!
    Can someone tell me how to handle
    floating point exceptions in C.I am working on a linux platform.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Don't generate any exceptions in the first place.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    24
    nice idea
    The program is a bit on the lengthier side so
    it is slightly difficult for me not to 'generate exceptions'..

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Check to see if you could be dividing by zero somewhere in the program.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Jun 2007
    Posts
    24
    ok i will try out the signal handler.
    There may be a small problem, i open another
    process during my program and the link here says that we need to be careful
    using it in a multi threaded process.Anyways i will try it out and let you know

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    Whether there is only one thread, or many doesn't matter.
    The code inside a signal handler is in it's own separate world, and those are the functions which are deemed to be signal safe.

    I'm not sure what you want to achieve following an FP exception.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Decimal places on Floating point number
    By manutdfan in forum C Programming
    Replies: 1
    Last Post: 10-29-2006, 11:56 AM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  3. floating point question
    By Eric Cheong in forum C Programming
    Replies: 8
    Last Post: 09-10-2004, 10:48 PM
  4. 2 questions about floating point and %
    By ams80 in forum C Programming
    Replies: 2
    Last Post: 08-14-2002, 10:55 AM
  5. Replies: 2
    Last Post: 09-10-2001, 12:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21