Question: What is the correct way to perform this operation?

```
399.9 / 100

```

What I would expect to see is

```
3.999

```

but the result is

```
3.9989999999999997

```

Answer: 
```
import 'dart:math';

double roundDouble(double value, int places){ 
    double mod = pow(10.0, places); 
    return ((value * mod).round().toDouble() / mod); 
}

```

then you would basically get

```
double num1 = roundDouble(12.3412, 2);
// 12.34

double num2 = roundDouble(12.5668, 2);
// 12.57

double num3 = roundDouble(-12.3412, 2);
// -12.34

double num4 = roundDouble(-12.3456, 2);
// -12.35

```
To make decimal operations you can use the [decimal package](https://pub.dev/packages/decimal).

```
final d = Decimal.parse;
print(d('399.9') / d('100')); // => 3.999

```