Re: infinities reformulated Chongkai Zhu (31 May 2005 07:17 UTC)
Re: infinities reformulated Aubrey Jaffer (31 May 2005 23:47 UTC)
Re: infinities reformulated Thomas Bushnell BSG (02 Jun 2005 15:23 UTC)
Re: infinities reformulated Aubrey Jaffer (02 Jun 2005 16:12 UTC)
Re: infinities reformulated Thomas Bushnell BSG (02 Jun 2005 16:16 UTC)
string->number Aubrey Jaffer (02 Jun 2005 19:10 UTC)
Re: string->number Thomas Bushnell BSG (02 Jun 2005 20:05 UTC)
Re: string->number Aubrey Jaffer (03 Jun 2005 01:59 UTC)
Re: string->number Thomas Bushnell BSG (03 Jun 2005 02:09 UTC)
Re: string->number Aubrey Jaffer (15 Jun 2005 21:10 UTC)
Re: string->number Thomas Bushnell BSG (16 Jun 2005 15:28 UTC)
Re: string->number bear (16 Jun 2005 16:59 UTC)
Re: string->number Aubrey Jaffer (17 Jun 2005 02:16 UTC)
Re: infinities reformulated bear (04 Jun 2005 16:42 UTC)
Re: infinities reformulated Aubrey Jaffer (17 Jun 2005 02:22 UTC)
Re: infinities reformulated bear (19 Jun 2005 17:19 UTC)
Re: infinities reformulated Aubrey Jaffer (20 Jun 2005 03:10 UTC)
Re: infinities reformulated bear (20 Jun 2005 05:46 UTC)
precise-numbers Aubrey Jaffer (26 Jun 2005 01:50 UTC)

Re: infinities reformulated bear 04 Jun 2005 16:42 UTC


On Thu, 2 Jun 2005, Aubrey Jaffer wrote:

> | From: Thomas Bushnell BSG <xxxxxx@becket.net>
> | There is no function "precision-of", so there is no need for an
> | answer.  Arbitrarily big precision arithmetic (generally) works pretty
> | well; you carry around symbolic representations and operate on them.
>
>To first order:
>
>  (define (precision-of x) (string-length (number->string x)))
>
>R5RS requires all numbers to have external representations; and it
>specifies the allowed formats.

I think the relevant section here is where it says that (paraphrase)
when exact numbers are operated on in such a way as to produce inexact
results, the results should have at least as much precision as the most
precise hardware floating-point representation available.

I read this as forbidding (or at least recommending against) immediate
floating-point representations that fit in 32 bits and truncate the
mantissa for a typetag.  So, when

  A) you take (sqrt 2) and
  B) 2 is an exact number, and
  C) your implementation cannot represent the result exactly,

the standard requires (or at least recommends) that your implementation
return a result with at least the "greatest hardware precision available",
which in most cases will be, I believe, what the C compiler refers to as
a "long" or "double" precision float.

But this is, of course, subject to some interpretation by different
implementors;  Nothing in R5RS says that the hardware representation
must be used; only that at whatever is used must provide at least
as much precision.  A squared, cubed, or n'th-powered  representation
may be available to represent square roots, cube roots, or nth roots
exactly, for example.  A logarithmic representation where the number
stored is an integer power of 1+epsilon may be used.  Etc.

For heavy math work, I want to be able to specify the precision used,
in one of several ways;  For example, by saying

(with-inexact-precision 128
  ...
  (sqrt 2)
  ...)

or

  (sqrt 2 :precision 128)

or (without keywords)

  (sqrt 2 128)

or something.  I think someone else has suggested that there ought
to be a different sqrt function for each desired precision, but I
don't like that method as much.

				Bear