mercredi 30 novembre 2016

C++ cout prints " inf " after operations between two big decimal number (long double)

My program takes a vector of long doubles as input (vector<long double>) and calculates different solutions using some methods.

Everything works fine untill I try these two numbers: 1.18973e+4932 and 1.18973e+4932.

It outputs the following:

<2: 1.18973e+4932 1.18973e+4932 > Min: 1.18973e+4932 Max: 1.18973e+4932 Range: 0 Midrange: inf Median: inf Mean: inf Variance: inf StdVariance : inf

After some researches, I found out that the value is exceeding the space in memory available for its own type.

So the question is: is it possible to handle this inside my code? Or the only solution is to input a smaller number?

Aucun commentaire:

Enregistrer un commentaire