Help with function
Gary L. Randolph
randolph at ektools.UUCP
Fri Jan 12 02:18:26 AEST 1990
In article <3198 at cbnewsj.ATT.COM> veenu at cbnewsj.ATT.COM (veenu.r.rashid) writes:
> On the compiler I'm using, abs() and strtol() seem to generate incorrect
>or at least inaccurate results. I'm using the following code:
>main(int argc, char *argv[])
>{
> double temp;
>
> temp = strtod(argv[1]); /* get the argument as a double */
> printf("Absolute value of %g is %g\n", temp, abs(temp));
>}
>Any code, suggestions, comments greatly appreciated.
Well, I can't duplicate the problem. I am using cfront 2.0 on a Sun and
all seems to work fine but I did have to make the following changes to
the code:
I used fabs() rather than abs()
I called strtod as follows:
temp = strtod(argv[1], NULL) /*ANSI definition*/ your
results was impossible. If that's all you are missing, I would be
dissappointed that the compiler didn't generate an error.
This is the sort of thing that would cause the described flakey
behavior.
:
-
)
Gary
More information about the Comp.lang.c
mailing list