Should I convert FORTRAN code to C?
der Mouse
mouse at mcgill-vision.UUCP
Mon Jun 20 18:34:07 AEST 1988
In article <10681 at agate.BERKELEY.EDU>, jerry at violet.berkeley.edu ( Jerry Berkman ) writes:
> As for "x = abs(x);", it does compile and load.
> However, it's calling a library function. What's wrong with that?
> (1) It's slow.
> (2) It returns the absolute value of integers. You can type it
> "float abs();" and it works on the VAX, but it may not work on
> all systems.
Doesn't work on our VAX. Your VAX must be using a different
floating-point format from the one in the VAX architecture manual.
I tried compiling and running this:
float abs();
main()
{
printf("%g\n",abs(123.456));
printf("%g\n",abs(-123.456));
}
and it gave me
-0.00210706
0.00210706
Of course, maybe you think that's what it means for it to work on the
VAX....but I daresay most people would disagree.
(You could also break down and use fabs, the floating-point absolute
value routine - or is that cheating?)
der Mouse
uucp: mouse at mcgill-vision.uucp
arpa: mouse at larry.mcrcim.mcgill.edu
More information about the Comp.lang.c
mailing list