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 79613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:10:24+00:00 2026-05-10T21:10:24+00:00

I have double (or float) variables that might be empty, as in holding no

  • 0

I have double (or float) variables that might be ’empty’, as in holding no valid value. How can I represent this condition with the built in types float and double?

One option would be a wrapper that has a float and a boolean, but that can´t work, as my libraries have containers that store doubles and not objects that behave as doubles. Another would be using NaN (std::numeric_limits). But I see no way to check for a variable being NaN.

How can I solve the problem of needing a ‘special’ float value to mean something other than the number?

  • 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-10T21:10:24+00:00Added an answer on May 10, 2026 at 9:10 pm

    In Visual C++, there is a non-standard _isnan(double) function that you can import through float.h.

    In C, there is a isnan(double) function that you can import through math.h.

    In C++, there is a isnan(double) function that you can import through cmath.

    As others have pointed out, using NaN’s can be a lot of hassle. They are a special case that has to be dealt with like NULL pointers. The difference is that a NaN will not usually cause core dumps and application failures, but they are extremely hard to track down. If you decide to use NaN’s, use them as little as possible. Overuse of NaN’s is an offensive coding practice.

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

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • 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 This will calculate the exact age. The fractional part of… May 11, 2026 at 11:09 am
  • added an answer I would probably do it by simply having some kind… May 11, 2026 at 11:09 am
  • added an answer First you would need to Regex.Escape() all the input strings.… May 11, 2026 at 11:09 am

Related Questions

I have double (or float) variables that might be empty, as in holding no
I have a need to run different code when a user clicks or double-clicks
I have a double value f and would like a way to nudge it
I have a Double which could have a value from around 0.000001 to 1,000,000,000.000
If I have a double (234.004223), etc., I would like to round this to
I have trouble comparing 2 double in Excel VBA suppose that I have the
I have a structure: struct pkt_ { double x; double y; double alfa; double
I have a script that did double inserts into the database with the same
I have a few combo-boxes and double spin boxes on my Qt Dialog. Now
I have a string that contains both double-quotes and backslashes that I want to

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.