From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5ab34cdc1859e33f X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Problem with pragmas Date: 1999/06/30 Message-ID: <377A71D9.D175448A@mitre.org>#1/1 X-Deja-AN: 495721226 Content-Transfer-Encoding: 7bit References: X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: The MITRE Corporation Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-06-30T00:00:00+00:00 List-Id: Robert Schien wrote: > I need to access the erf (Gaussian error function) from the C-Math-Library. > But the following program does not work correctly: > But when I execute pragtest, the printed result is always 0.0. > (The correct result is something between 0 and 1, in this case > about 0.32) > > What did I miss? It could be a bug, or a library function that just hasn't been implemented in that version of Unix. But there is another possibility, one of those fun C rules. The C math libraries actually take double parameters, and the C compiler converts from float if necessary. In fact all scalar floating point parameters are passed as double or in floating point registers. On arcitectures where floating point parameters are passed in registers, you won't notice a problem. (Then why have C_float in Interfaces.C? Because you will often have floats in structs that you need to interface to.) I'm not sure about FreeBSD-4.0, but if the call sequence was defined so it would work on 386 chips or earlier, the parameters may not be passed in registers. (It also might be a good idea for Ada compilers to warn when C interfaces are declared with C_float parameters. Sometimes it is right for example for OS calls. Also on most hardware the parameters will be passed in floating point registers, so the compiler shouldn't force the change.) -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...