Mathematical rounding

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 15 22:24:24 PDT 2014


On 10/15/14, 8:11 PM, Elena wrote:
> Hi,every one!
> How can I realize mathematical rounding (not banking) for Double in D
> 0.4 -> 0
> 0.5 -> 1
> 1.5 -> 2
> 2.5 -> 3
> 3.5 -> 4  ?
>
> Thank you.

Add 0.5 and then cast to integral. -- Andrei


More information about the Digitalmars-d mailing list