Thread: Is there an "error value" I can use for a double?

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    Is there an "error value" I can use for a double?

    I'm doing an algorithm that returns a double if the value is proper, is there a constant I can use to indicate the value is an error. The numbers that do properly return can be negative or positive so -1's out. Is there a system independent value that indicates a bad double value?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    NaN? (Not a number)

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    hmm, how about that. Thanks.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by indigo0086 View Post
    I'm doing an algorithm that returns a double if the value is proper, is there a constant I can use to indicate the value is an error. The numbers that do properly return can be negative or positive so -1's out. Is there a system independent value that indicates a bad double value?
    Why not throw an exception?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copying 2-d arrays
    By Holtzy in forum C++ Programming
    Replies: 11
    Last Post: 03-14-2008, 03:44 PM
  2. need some help with last part of arrays
    By Lince in forum C Programming
    Replies: 3
    Last Post: 11-18-2006, 09:13 AM
  3. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  4. Unknown Math Issues.
    By Sir Andus in forum C++ Programming
    Replies: 1
    Last Post: 03-06-2006, 06:54 PM
  5. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM