# Problem on calculating a number

**URL:** https://community.freefem.org/t/problem-on-calculating-a-number/821
**Category:** General Discussion
**Created:** [February 20, 2021, 2:36am UTC](https://community.freefem.org/t/problem-on-calculating-a-number/821 "2021-02-20T02:36:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hezl09](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@hezl09](https://community.freefem.org/u/hezl09)
#### Post date: [February 20, 2021, 2:36am UTC](https://community.freefem.org/t/problem-on-calculating-a-number/821/1 "2021-02-20T02:36:21Z")

</div>

Hello, I met a problem in FreeFEM++ on calculating a integer number, which can be simplified as the following problem. I defined a integer M in the following two ways, and I expected that they give me the same number 2. However, I got M1 = 1 and M2 = 2 from the output. Why would this occur? Can anyone help me with this problem? Thanks!

int M1 = 20\*(1.0-0.9);  
int M2 = 20\*0.1;  
cout \<\< "M1: " \<\< M1 \<\< ", M2: " \<\< M2 \<\< endl;

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [February 4, 2022, 5:17pm UTC](https://community.freefem.org/t/problem-on-calculating-a-number/821/2 "2022-02-04T17:17:19Z")

</div>

The problem is due to basic represation of floating number  
and 0.9 au 0.1 have no exact repression in base 2  
so you have roundoff error and you see that here  
I compute

```auto
int M1 = 20*(1.0-0.9);
int M2 = 20*0.1;
cout << "M1: " << M1 << ", M2: " << M2 << " " << 20*(1.0-0.9)-2 << endl;

```

and the get

```auto
M1: 1, M2: 2 -4.44089e-16

```
