R-beta: R-0.62.1 under Digital Unix

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Jul 3 16:32:15 CEST 1998


Albrecht Gebhardt <agebhard at zidsrv.sci.uni-klu.ac.at> writes:

    (on    n = abs(n2 - n1) + 1 + FLT_EPSILON;)


> Now I changed "abs" to "fabs", ... and it works !!

Yay! I though it would be something like that.

This really should be fabs on all platforms, I think. 

abs() expects an integer argument and returns one too. However, if it
is declared properly, the compiler should make the appropriate casts.

Linux has the declaration in stdlib.h which gets included via
src/include/Mathlib.h, so one would assume that it is POSIXly correct?
Solaris has the same.

If it is not declared, it passes a double to a function expecting an
integer, which resets what it thinks is the sign bit and returns some
part of the argument, believing it to be an integer, which is certain
disaster. 

So, you probably want to snoop around in Digital Unix and see whether
it actually contains a declaration of abs().


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list