Re: R-alpha: .Machine object

George White (gwhite@cabot.bio.dfo.ca)
Wed, 13 Nov 96 9:10:11 AST


Message-Id: <199611131311.OAA15701@hypatia.math.ethz.ch>
From: George White <gwhite@cabot.bio.dfo.ca>
Subject: Re: R-alpha: .Machine object
To: r-testers@stat.math.ethz.ch
Date: Wed, 13 Nov 96 9:10:11 AST

> 
> Friedrich Leisch writes:
>  > 
>  > Hi,
>  > 
>  > I would like to port the S fracdiff package to R. Everything works
>  > fine, except that I need the S .Machine object, providing a lot of
>  > Machine constants such as max double, min double, eps, aso
>  > 
>  > Are there any plans on including .Machine in one of the next releases?
> 
> The S .Machine object seems to include all sorts of information I
> can't really see a use for (isn't virtually everything ieee these days?).
>
Well, there are still a lot of vaxen in use, but it is legit to say that
R requires IEEE.  

> I have some code which will certainly produce all this information,
> but it would be cleaner just to use the useful subset of values in
> <float.h> and <limits.h>.  We could give them the same names as the S
> values.
> 
> Also, since R is strictly double precision it seems to make sense only
> to have the double precision versions of these values.
> 
It could be useful to know the single precision parameters when dealing
with external programs.  
> Opinions anyone?

There are two questions here:

1.  What should be in a .Machine for R?

Mimic what S does.  Since R can be used as a high-level shell that
calls procedures written in other languages, completeness in 
.Machine is a virtue.    

I prefer run-time tests such as those in the machar code from netlib over
the use of stored values because some of the machine parameters can be
affected by compiler flags and runtime libraries (I was recently bitten by
difference between the setting of the underflow behaviour in Win32 vs OS/2
such that the same binary gave different results when run in the two envts).
It is not unusual to find compiler defaults that disable IEEE gradual 
underflow, and this can have a major impact on some numerical algorithms, 
so it is very worthwhile to include the rounding mode in .Machine.

2.  How to implement this with minimal fuss?

Use <limits.h>, which in my experience has been reliable.  
If the machar code is acceptable in GPL'd software, use run-time machar
values in preference to <float.h> (what we really need is a GNU <float.h>
that performs runtime tests!).

--
  George N. White III                | Internet: <aa056@chebucto.ns.ca>
  Department of Fisheries and Oceans | DFO email: GWhite@BIOnet.BIO.DFO.ca
  Ocean Sciences Division            | Time Zone: Atlantic (AST4ADT)
  Bedford Institute of Oceanography  | phone: (08:00-16:00)
  P.O. Box 1006                      |     902.426.8509 (office)
  Dartmouth, Nova Scotia             |     902.426.9388 (FAX)
  CANADA               B2Y 4A2       |     902.426.3793 (emergencies)

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-