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

Re: number syntax




>    ... the original proposal is such that both exact and inexact
>    flonums are possible (and desirable), and similarly for the other
>    types.  Although we have not implemented it, we have an implementation
>    in mind, and it is orthogonal: for each type of number, there is a bit
>    specifying whether it is exact or not.

In the presence of an exactness indicator bit, I would be all for adding 
an exactness indicator to number syntax.  This would allow the user to 
explicitly specify whether a number is exact or inexact, independent
of its type.  For example, one could use:

	-3.14, 7/8, 2+7i,

to mean an exact quantities, and:

	~-3.14, ~7/8, ~2+7i

to mean inexact quantities.  (I use tilde to indicate "approximately" as 
opposed to "not" like in C).  

This explicit notation would allow exactness to be preserved by coersion
operators:

	(float ~7/2)  =>  ~3.5

as well as removing ambiguities from operations such as:

	(sqrt  4)    =>   2
	(sqrt ~4)    =>  ~2
	(sqrt  4.0)  =>   2.0   ; this would have been considered inexact
				; if all flonums were inexact
	(sqrt  3)    =>  ~1.7320508075688772  ; finite precision
	(sqrt  -4)   =>   0+2i  ; this might have been considered inexact too