Question: I'm making a REST call and receiving this XML back:

```
<replacement><![CDATA[this is &amp; ampersand]]></replacement>

```

I've substringed out the bit that I really care about:

```
this is &amp; ampersand

```

How do I now decode this snippet into (I'm not using yaws):

```
this is & ampersand

```

Answer: 
It's most likely because of the integer cast. Depending on your inputs, the results can be close and appear to have the same result because of rounding during the integer cast. Use double in your function instead.
You are doing floating point arithmetic and returning the result to int. I would change variables to floats or doubles were needed.