[EMAIL PROTECTED] wrote:
>
> Hi,
>
> That works, but it's not exactly what I wanted. I want to round a
> decimal and print it, not convert it to string, shorten it and then
> print it.
>
I haven't stress-tested this for valid ranges, but here's a QAD
round: func [n [number!] p [integer!] /local factor] [
factor: power 10.0 absolute p
(to-decimal to-integer (n * factor + 0.5)) / factor
]
which does
>> round 3.1415926535 4
== 3.1416
>> round 3.1415926535 3
== 3.142
>> round 3.1415926535 2
== 3.14
>> round 3.1415926535 1
== 3.1
>> round 3.1415926535 0
== 3
However, beware of overflow...
>> round (186282.25 * 60 * 60) 1
== -188377359.2
Maybe that'll give you a kick-start.
-jn-