Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 95509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:40:10+00:00 2026-05-10T23:40:10+00:00

In my programs infinity usually arises when a value is divided by zero. I

  • 0

In my programs infinity usually arises when a value is divided by zero. I get indeterminate when I divide zero by zero. How do you check for infinite and indeterminate values in C++?

In C++, infinity is represented by 1.#INF. Indeterminate is represented by -1.#IND. The problem is how to test if a variable is infinite or indeterminate. Checking infinity is relatively straightforward: You find the infinity definition in your particular C++. For my case (VS2003), it is std::numeric_limits::infinity(). You have to include ‘limits’ in order to use it. You can assign this infinite value to a variable and you can compare it to some value in order to check if that value is infinite.

Indeterminate is a little tricky, because you cannot compare an indeterminate value to some other value. Any comparison returns false. You can use this property to detect an indeterminate value by comparing it to itself. Let’s say you have a double variable called aVal. Under normal conditions, aVal != aVal returns false. But if the value is indeterminate, aIndVal != aIndVal returns true. This weird situation is not present for infinite values, i.e. aInfVal != aInfVal always returns false.

Here are two functions that can be used to check for indeterminate and infinite values:

#include 'limits.h' #include 'math.h'  bool isIndeterminate(const double pV) {     return (pV != pV); }   bool isInfinite(const double pV) {     return (fabs(pV) == std::numeric_limits::infinity()) } 

Are there better ways for these checks, am I missing anything?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:40:10+00:00Added an answer on May 10, 2026 at 11:40 pm

    For Visual Studio I would use _isnan and _finite, or perhaps _fpclass.

    But if you have access to a C++11-able standard library and compiler you could use std::isnan and std::isinf.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Largely yes, as long as you don't ever reset it… May 11, 2026 at 11:42 am
  • added an answer s/\(get[A-Z][A-Za-z0-9]*_\)\([A-Z]\)/\1\L\2/g Test: $ echo 'getFoo_Bar' | sed -e 's/\(get[A-Z][A-Za-z0-9]*_\)\([A-Z]\)/\1\L\2/g' getFoo_bar May 11, 2026 at 11:42 am
  • added an answer Depends what you mean by 'run'. To just execute the… May 11, 2026 at 11:42 am

Related Questions

In my programs infinity usually arises when a value is divided by zero. I
In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ is the list of installed programs in my machine (at least most
One thing that annoys me when debugging programs in Visual Studio (2005 in my
Typing in programs longer than 50 characters got old really fast on my HP49g+.
In my program, I have been receiving an error when I use a command-line
In my program, how can I read the properties set in AssemblyInfo.cs: [assembly: AssemblyTitle(My
In my program I have one array with 25 double values 0.04 When I
One of classes in my program uses some third-party library. Library object is a
All objects in my program inherit from a Container class. The Container class has
Some loading routines in my program takes to long to complete. I want a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.