Reputation: 43
The program takes for parameter one double and its doing computation with long float point values. eg double myvar= n*0.000005478554 /298477
.
The problem is that im not sure that the real computational value is inserted to myvar.
because whenvever i change n it produce the same thing cout<<"myvar ="<<myvar;
What is the biggest type in c++ that can be used for maximum accuracy? Does a buffer overflow caused by this code because double variable cant hold too much info ? If yes what can happen and how can i detect it for later use?
Upvotes: 0
Views: 5001
Reputation: 179809
double
will hold values much smaller (and bigger) than 0.000005478554 /298477
. Any problem that you have is almost certainly caused by a bug in your code. Show it!
Try to reduce your problem to a few lines. This kind of problems can be reproduced with something as small as
#include <iostream>
int main() {
double myvar = 7 * 0.000005478554 /298477;
std::cout << myvar;
}
Upvotes: 3