# how am i failing to do a simple division math problem?

hi,

i always read that double has fractional capability, so i have tried a simple 5/3 problem, but i'm getting 1.0

```int  x = 5;
int y = 3;

```

any help on how can i get the actual 1.6?

zelda_lee:

hi,

i always read that double has fractional capability, so i have tried a simple 5/3 problem, but i'm getting 1.0

any help on how can i get the actual 1.6?

Yes, so do not use an int.

The math is being done in Int space because that's the type of memory you used to store the original numbers.  This is a common compiler issue in many programming languages.  Try changing at least X to a double and see what happens...

Shalem Loritsch #:
The math is being done in Int space because that's the type of memory you used to store the original numbers.  This is a common compiler issue in many programming languages.  Try changing at least X to a double and see what happens...

yes it works as it should if both inputs are double

thanks

zelda_lee: so i have tried a simple 5/3 problem, but i'm getting 1.0

Rare code issue

Fernando Carreiro, 2021.07.23 22:20

Please understand that dividing by 100 or dividing by 100.0 will give totally different results.

In the former, 100 is considered an Integer literal constant and so it will carry out integer division which will truncate the decimal values.

In the latter, 100.0 will be considered a floating-point literal constant and it will carry out floating-point division which will keep the decimal values.

This is the principal behind the problems you are having. So, to prevent this, either use a floating-point literal constant or typecast the variable into a (double).

Example:

```Print( "90   / 100   = ", 90   / 100   );
Print( "90   / 100.0 = ", 90   / 100.0 );
Print( "90.0 / 100   = ", 90.0 / 100   );
Print( "90.0 / 100.0 = ", 90.0 / 100.0 );
```
```2021.07.23 21:26:57.060 TestCopy EURUSD,H1: 90   / 100   = 0
2021.07.23 21:26:57.060 TestCopy EURUSD,H1: 90   / 100.0 = 0.9
2021.07.23 21:26:57.060 TestCopy EURUSD,H1: 90.0 / 100   = 0.9
2021.07.23 21:26:57.060 TestCopy EURUSD,H1: 90.0 / 100.0 = 0.9```

```double Average = (double) Bars /          Found;