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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:16:44+00:00 2026-05-26T01:16:44+00:00

I am printing some data from a C++ program to be processed/visualized by ParaView,

  • 0

I am printing some data from a C++ program to be processed/visualized by ParaView, but I am having a problem with floating point numbers. Paraview supports both Float32 and Float64 data types. Float64 is equivalent to double with the typical limits +/-1.7e +/- 308. But, my code is printing numbers like 6.5e-318. This is throwing errors in ParaView when reading the data. I have verified that rounding those smalls numbers to zero make the errors in ParaView disappear. I am not sure why I have such “high precision” output, maybe is because some numbers are stored in higher precision than double. For example, the following code reproduces the same behavior on my system:

#include <iostream>
int main(void)
{
  const double var1 = 1.0e-318, var2 = 1.5e-318;
  std::cout << 1.0e-318 << std::endl; 
  std::cout << var1 << std::endl; 
  std::cout << var1 - var2 << std::endl; 
  std::cout.setf(std::ios_base::fixed | std::ios_base::scientific, std::ios_base::floatfield);
  std::cout << 1.0e-318 << std::endl; 
  std::cout << var1 << std::endl; 
  std::cout << var1 - var2 << std::endl; 

  return 0;
}

My output is:

9.99999e-319
9.99999e-319
-4.99999e-319
9.99999e-319
9.99999e-319
-4.99999e-319

My system is a Mac OS X Snow Leopard and I tested the above with GCC 4.2 and GCC 4.6 with the flags -m32, -m64 and -ffloat-store (not sure if this is useful).

Actually the output for me is fine, but for ParaView is not. I just want to know why I have this difference. I am very likely ignoring something related with floating point numbers which could be important. Could you please please give me some clue about this output/numerical behavior for doubles?

  • 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. Editorial Team
    Editorial Team
    2026-05-26T01:16:45+00:00Added an answer on May 26, 2026 at 1:16 am

    Subnormal numbers, i.e. numbers with the smallest-possible exponent and leading zeros in the fraction, can be smaller than 1E-308, down to 1E-324. You can probably filter them out using std::numeric_limits.

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

Sidebar

Related Questions

I'm having some trouble with Visual Studio 2008. Very simple program: printing strings that
I'm having a problem trying to print some data of a table. I'm new
I'm using Qt and QProcess to read some data from other tools and printing
Hi i am currently getting some data from my database table and printing it
I am getting data from log file and printing it but it was not
I have been researching options for printing report-like data via a web application. Some
I need to do some printing from my Java Swing application. I have tried
I have some data from database coming out in a loop. Each of these
I'm writing some quick code to try and extract data from an mp3 file
I'm having a bit of trouble printing some of the forms in our Smart

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.