Question: I am trying to interface with a machine over RS232 and the machine requires all input to have a decimal separator or else it assumes the decimal position. E.G. If I send `25` it will interpret that as `0.025`, but `25.000` or `25.` will be received properly as `25.000` 

I tried [`Math.Round`](https://msdn.microsoft.com/en-us/library/System.Math.Round(v=VS.110).aspx) but for whole number values it doesn't include the trailing zeros.

So, if I have

```
float a = 90;
float b = cos(24);
comPort.WriteLine("G01 A" + a + " B" + b);

```

What do I need to add so that it forces 3 decimals places? I'm not concerned about how it's rounded nor if it truncated.

Answer: 
Use the ToString() method on a and b like this:

```
comPort.WriteLine("G01 A" + a.ToString("F3") + " B" + b.ToString("F3"));

```

That should do it.
Instead of using concatenation, use String.Format

```
comPort.WriteLine(String.Format("G01 A{0:F3} B{1:F3}", a, b));

```