user25779: I am having a double value for example: 34.26 or 11.92 or 2.51. It should be rounded to the nearest 0.5 so 1.34 -> 1.50 and 32.78 -> 33 and 21.09 -> 21.00 
How do to do this?

user18478: It is a very bad idea to use float.
That being said. multiply by 2 and do a standard round.
Then divide back by 2.
For example:
1.34     *2 = 2.68
round(2.68) = 3
3        /2 = 1.5

and 
32.78    *2 = 65.56
round(65.56)= 66
66       /2 = 33


25779: <p>I am having a double value for example: 34.26 or 11.92 or 2.51. It should be rounded to the nearest 0.5 so 1.34 -> 1.50 and 32.78 -> 33 and 21.09 -> 21.00 </p>

<p>How do to do this?</p>
 18478: <p>It is a very bad idea to use float.<br>
That being said. multiply by 2 and do a standard round.<br>
Then divide back by 2.</p>

<p>For example:</p>

<pre><code>1.34     *2 = 2.68
round(2.68) = 3
3        /2 = 1.5
</code></pre>

<p>and </p>

<pre><code>32.78    *2 = 65.56
round(65.56)= 66
66       /2 = 33
</code></pre>
