Naive Number Question 
Author Message
 Naive Number Question

Hi.

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

Thanks.

- Rob.



Fri, 30 May 2003 02:30:23 GMT  
 Naive Number Question

Quote:
> Hi.

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

round/(number, expt(10, - n)) / expt(10, n)

[probably don't have the syntax right, but you get the idea]

Or write your self a scaled/decimal number type ;-).



Fri, 30 May 2003 03:33:03 GMT  
 Naive Number Question

Quote:

> Hi.

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

On a binary machine there is no more efficient way to do that than to
multiply it by 10^n, round it, and then multiply by 10^-n.

-- Bruce



Fri, 30 May 2003 04:25:25 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Naive Number Question

2. naive type checking II (not so naive?)

3. Naive parallel implementation of Mersenne Twister random number generator

4. Naive implementation of parallel Mersenne Twister (MT) pseudorandom number generator

5. Questions from a naive user

6. Questions from a naive st programmer

7. Naive Forth questions

8. Extremely naive (and probably stupid) question

9. (Yet another) naive question

10. Naive question

11. Naive question

12. Another naive question

 

 
Powered by phpBB® Forum Software