Question 14.6

How do I round numbers?


The simplest and most straightforward way is with code like

(int)(x + 0.5)
This technique won't work properly for negative numbers, though.


Read sequentially: prev next up top


This page by Steve Summit // Copyright 1995 // mail feedback