Why when I try to store this big number inside a double I obtain this strange result into a Java application?
<p>I have the following problem trying to store the correct output of this SQL query into a <strong>double</strong> variable into a Java applcation.</p>

<p>So I have this <strong>SQL</strong> query:</p>

<pre><code>SELECT sum(anagraficaEdificio.imp_tot_ind - anagraficaEdificio.imp_cof) FROM TID003_ANAGEDIFICIO anagraficaEdificio
INNER JOIN TID002_CANDIDATURA candidatura ON (candidatura.PRG_PAR = anagraficaEdificio.PRG_PAR AND candidatura.PRG_CAN = anagraficaEdificio.PRG_CAN)
INNER JOIN TID001_ANAGPARTECIPA anagPartecipa ON(anagPartecipa.PRG_PAR = candidatura.PRG_PAR)
INNER JOIN anagrafiche.TPG1029_PROVNUOIST provNuovIst ON (provNuovIst.COD_PRV_NIS = anagPartecipa.COD_PRV_NIS)
WHERE FLG_GRA=1
</code></pre>

<p>Performing this query directly on my database (using its client)  I obtain this correct numeric result: <strong>36481888,47</strong></p>

<p>Ok, so I have implemented it into a Java application (using SpringDataJpa, but I think that this is not important, because it is performed as <strong>SQL native query</strong>) by:</p>

<pre><code>@Query(value = "SELECT sum(anagraficaEdificio.imp_tot_ind - anagraficaEdificio.imp_cof) FROM TID003_ANAGEDIFICIO anagraficaEdificio "
         + "INNER JOIN TID002_CANDIDATURA candidatura ON (candidatura.PRG_PAR = anagraficaEdificio.PRG_PAR AND candidatura.PRG_CAN = anagraficaEdificio.PRG_CAN) "
         + "INNER JOIN TID001_ANAGPARTECIPA anagPartecipa ON(anagPartecipa.PRG_PAR = candidatura.PRG_PAR) "
         + "INNER JOIN anagrafiche.TPG1029_PROVNUOIST provNuovIst ON (provNuovIst.COD_PRV_NIS = anagPartecipa.COD_PRV_NIS) "
         + "WHERE FLG_GRA=1", nativeQuery = true)
double getImportoFinanziabileNazionale();
</code></pre>

<p>that perform the original query.</p>

<p>The problem is that when I call this method by:</p>

<pre><code>double risultato = tid003AnagedificioRepository.getImportoFinanziabileMiurNazionale();
</code></pre>

<p>the value stored into the <strong>risultato</strong> variable is not <strong>36481888,47</strong> (the correct one) but I obtain this value <strong>3.648188847E7</strong>.</p>

<p>Why it contains an E inside it? Is something related to an exponensial notation or something like this? How can I obtain the oringial <strong>36481888,47</strong> value returned by my query into my Java application? Is it related to the use of <strong>double</strong>?</p>

<p>What am I missing? How can I fix this issue?</p>