Thread: floating point exception

  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,210
    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,210
    Check to see if you could be dividing by zero somewhere in the program.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

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, 12:56 PM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  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