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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c86eb13dd395066 X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: CRC in Ada? Date: 1997/03/12 Message-ID: <33269D56.6E8E@elca-matrix.ch>#1/1 X-Deja-AN: 225012048 References: <1997Mar2.220652@nova.wright.edu> <1997Mar5.131846.1@eisner> <5fmo1k$adm@mulga.cs.mu.OZ.AU> <1997Mar6.114441.1@eisner> <1997Mar7.090814.1@eisner> <33206340.2616@bix.com> <1997Mar7.202252.1@eisner> <5fub2s$8k@fozzie.sun3.iaf.nl> Organization: ELCA Matrix SA Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1997-03-12T00:00:00+00:00 List-Id: > I do agree that it is surprising how much extra time these comparisons > add (that of course is HIGHLY target dependent, so the other thing to > think about in getting enthusiastic about this optimization is to > find out how much it will help on various targets). I think that if the C library functions are good enough for C and FORTRAN people, they should be good enough for Ada people also, without adding these comparisons. Who wants to write algorithms that depend on the sine function with cycle => 90.0 (which is a model number) returning exactly 1.0, and other such particular cases ? Floating point is approximate by nature. This is another instance (the other being simple text IO, see other threads going on) where Ada is by nature less effective than C, and the sad thing is that it is not in the language itself but in standard libraries that are over-featurized: who needs column and line numbers, and a log function that is guaranteed to return exactly 0.0 when called with exactly 1.0. I think such special needs are better addressed by explicit coding: use an explicit line counter for that seldom occasion where you need line numbers, or put the test for = 1.0 before you call Log when you really need it to be a special case. It would be nice if there was a version of the numerics packages with direct calls to the library and comparisons only for the cases where an exception must be raised (such as Log of a negative value). One way to achieve this would be to have two versions of the elementary functions: Ada.Numerics.Generic_Elementary_Functions and Ada.Numerics.Pedantic.Generic_Elementary_Functions :-) or an installation option for the compiler.