From: Eddie R. <er...@bm...> - 2008-07-08 14:54:41
|
On Tue, 2008-07-08 at 15:05 +0100, Libor Spacek wrote: > OK, fair enough. I was working up to the "mad" idea which is probably too revolutionary and upsetting to everyone. Sorry, but I don't know enough to be upset ;-) > The idea is that all the current numeric types become transparent (hidden) to the user. Promotions take place automatically (in the background) whenever a loss of information would otherwise occur, such as: > and demotions too: Scheme does some of this except numbers are separated into two groups "exact" and "inexact." The only explicit conversions required are between exact and inexact except were it really makes since like (sqrt 5). Demotions of inexact (floating point) to exact is the only thing missing but for good reason see (sqrt 1/5) below. Example: > (/ 4 3) 1 1/3 Note the space between 1 and 1/3. MzScheme returns a mixed number. > (/ 4.0 3) 1.3333333333333333 > (/ 4 3.0) 1.3333333333333333 > (sqrt 4.0) 2.0 > (sqrt 4) 2 > (sqrt 4/9) 2/3 > (sqrt 1/5) 0.4472135954999579 We don't want and exact approximation to an irrational number do we? Yes, I know that is really a rational number in disguise, but it lets the user know that it really is an approximation instead of letting them believe it is exact. > (expt 4 1/2) 2 > (sqrt -4) 0+2i > (expt -4 1/2) 0+2i > (sqrt -4.0) 0+2.0i > (expt > (inexact->exact 0.123) 553942754166571/4503599627370496 e.r. |