This is my double:

double determinant = 2.8*5*-9.5;


It should print out -133, right?

It prints out some weird junk like: 1.8e + 04


How can I correct this?

Recommended Answers

Show us how you're printing it out.

Jump to Post

It works for me:

#include <iostream>
using namespace std;
int main()
{
		double determinant = 2.8*5*-9.5;
		cout << "determinant = " << determinant<<endl;
		return 0;
}

./Temp
determinant = -133
Jump to Post

All 8 Replies

Show us how you're printing it out.

cout << "determinant = " << determinant;

;)

It works for me:

#include <iostream>
using namespace std;
int main()
{
		double determinant = 2.8*5*-9.5;
		cout << "determinant = " << determinant<<endl;
		return 0;
}

./Temp
determinant = -133

might be your compiler -- mine (VC++ 6.0) prints -133. what compiler are you using?

I'm using an older version of Bloodshed. I guess that could be the problem...... But if it works, then I will be extremememememmeemlllllyyyyyy happy.

Dev-C++ version 4.9.9.2 works ok too. Suggest you upgrade to current version.

Yeah, I'm downloaded the very latest version right now. I'll let you know how it goes.

Alright, it worked. Thanks for all the help guys.

PS: Why would a compiler have problems with a double like that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.