Ask coding questions

← Back to all posts
Scientific Notation Answer Problem
btd (2)

Does anyone know how to get a number answer that isn't in scientific notation? In the C++ code segment below, the lower four data types come with an "e" and either a "+" or "-" on them. Is there a way to not have numbers displayed like that? And why does this happen in the first place?

#include <iostream>
#include <climits> // climits is needed to display min and max values for INT & LONG

#include <float.h> //float.h is needed to diaplay min and max values for FLT & DBL

using namespace std;

int main()
{
cout << "INT_MIN is " << INT_MIN << endl;
cout << "INT_MAX is " << INT_MAX << endl;
cout << "LONG_MIN is " << LONG_MIN << endl;
cout << "LONG_MAX is " << LONG_MAX << endl;
cout << "FLT_MIN is " << FLT_MIN << endl;
cout << "FLT_MAX is " << FLT_MAX << endl;
cout << "DBL_MIN is " << DBL_MIN << endl;
cout << "DBL_MAX is " << DBL_MAX << endl;

return 0;
}

Answered by rediar (134) [earned 5 cycles]
View Answer
Voters
btd (2)
Commentshotnewtop
rediar (134)

cout<<fixed<<"something here: "<<x<<"something here"<<t<<"something here"<<x+t<<endl;
use std::fixed
please up vote if helpful