<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61658>61658</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Approximate result of floating-point operation with -O2
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fedr
</td>
</tr>
</table>
<pre>
The following program
```
#include <iostream>
#include <limits>
int main() {
double A = std::numeric_limits<double>::max();
double C = -0.1;
double V = A * C - A * C;
std::cout << V << std::endl;
}
```
if compiled with `-O2` option, prints `-4.9896e+290` instead of `0`. Is it normal?
Online demo: https://godbolt.org/z/fqf7xaYhq
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsksuOnDwQhZ-m2JRAYAMNCxYM_SP9q9lEkbKKDBTgyBfGNplJnj6CnksuLSEw_qqOj49KeC8XQ9RA8QDFNRJ7WK1reppcNNjpR_NpJZytUvZZmgU3ZxcnNKRXSFso09fn9su4NKPaJ0LgnbQ-OBIa-H_3sJJaBv8Bz7c0AbWQBlgFrEa4PNz2EREnuw-KsEXgV_RhAt4Cb82uycnx65tcdys7dE-uxctNDPi_Wt2pFadJdo9-PmmLwFrsMH5b_VH67mO0eziuBbw7G8_FOyUzqfc-uFzvxidnHK3epKIJn2VYEco0fmRQpmi3IK0B1uHmpAn-RHlSV3VJwB5YfaigND6QmNDOBz-2EvzfowxorNNCAe9_D_vRKGkIJ9IWeItrCJs_7LIeWL_YabAqJNYtwPqfwPr5ab68iC_rUzQ1fKp5LSJqsvJSF1WeVyxamyKfq7Lm88xnkbK6KgcSJZspZUNOl8scyYaljKec8azI8pwlQznWORNZnQ1FltMAeUpaSJUo9V0fZ0fS-52aMiuLKlJiIOXfBtU1R1E87IuHPFXSB__RFmRQ1LTb5uyL1CIQOvK7Ckc2s7IiSLPEmz3mzW7kxBHvLfT4kUW7U81fcciw7kMyWg2sP055_cSbs99oDMD606kH1p9mfwUAAP__lXv6Cw">