[Prev][Next][Index][Thread]

Re: Naive Number Question



Rob Myers wrote:

> Hi.
>
> How can I round a number (a <float>) to the nearest  n  decimal places in (Gwydion) Dylan?
>
> Thanks.
>
> - Rob.

This is the Fortran stuff I used to do :-) I am sure you can find the dylan equivalent

rounded =  int(unrounded * 10^n + 0.5) /10^n

where int is a function that truncates a float and returns the integer part. Of course some
addl scaffolding is reqd to handle neagtive numbers etc

HTH

P Asokan



References: