Naive Number Question 
Author Message
 Naive Number Question

Thank you very much. :-)

- Rob.

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 04:06:08 GMT  
 Naive Number Question

Quote:

> 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



Fri, 30 May 2003 10:12:08 GMT  
 
 [ 2 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