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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!out04b.usenetserver.com!news.usenetserver.com!in02.usenetserver.com!news.usenetserver.com!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny03.POSTED!0e8a908a!not-for-mail From: Hyman Rosen User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: why learn C? References: <1172144043.746296.44680@m58g2000cwm.googlegroups.com> <1172161751.573558.24140@h3g2000cwc.googlegroups.com> <546qkhF1tr7dtU1@mid.individual.net> <5ZULh.48$YL5.40@newssvr29.news.prodigy.net> <1175215906.645110.217810@e65g2000hsc.googlegroups.com> <1175230700.925143.28490@n59g2000hsh.googlegroups.com> <6XbPh.4025$u03.802@newssvr21.news.prodigy.net> <1175491660.511530.58430@y80g2000hsf.googlegroups.com> <1175566924.442636.199470@o5g2000hsb.googlegroups.com> In-Reply-To: <1175566924.442636.199470@o5g2000hsb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 12 Apr 2007 15:47:36 GMT NNTP-Posting-Host: 162.84.197.141 X-Complaints-To: abuse@verizon.net X-Trace: trndny03 1176392856 162.84.197.141 (Thu, 12 Apr 2007 11:47:36 EDT) NNTP-Posting-Date: Thu, 12 Apr 2007 11:47:36 EDT Xref: g2news1.google.com comp.lang.ada:14941 Date: 2007-04-12T15:47:36+00:00 List-Id: jimmaureenrogers@worldnet.att.net wrote: > I discovered that C++ template language does not allow the > specification of a floating point value as a template parameter. In C++, instantiations are considered the same if their parameters are the same, and the standards committee did not want the burden of defining T<3.0*(1.0/3.0)> vis a vis T<1.0>. > one cannot write a C++ template to handle range-specified > floating point classes. Of course this is wrong. Every floating point number that you write in a program is in fact a rational number, and therefore depending on the purpose those numbers will have in the template, they be represented using small sets of integers in a variety of ways. The template itself can then assemble these parts into a floating-point constant and use it. Or if that's too burdensome, references to floating-point variables are permitted, so getting what you want looks rather like Ada generic instantiation. > But you cannot write a template equivalent to: > type Voltage_Type is digits 11 range -5.0..5.0; Using the variable reference approach, we can do template class FloatRange; extern double const vtlo = -5.0; extern double const vthi = 5.0; typedef FloatRange Voltage_Type;