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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!t-online.de!tsicnews.teliasonera.com!news.otenet.gr!news.grnet.gr!newsfd02.forthnet.gr!not-for-mail From: Ioannis Vranos Newsgroups: comp.lang.ada,comp.lang.c++ Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Thu, 24 Mar 2005 04:38:09 +0200 Organization: FORTHnet S.A., Atthidon 4, GR-17671 Kalithea, Greece, Tel: +30 2109559000, Fax: +30 2109559333, url: http://www.forthnet.gr Message-ID: <1111631889.495954@athnrd02> References: <1110329098.642196@athnrd02> <1110361741.551255@athnrd02> <422edaec$0$26554$9b4e6d93@newsread4.arcor-online.net> <1111464133.508323@athnrd02> <423fe9df$0$11476$9b4e6d93@newsread2.arcor-online.net> <1111521825.653841@athnrd02> <424094b0$0$11481$9b4e6d93@newsread2.arcor-online.net> <1111568404.687226@athnrd02> <1111572591.296439@athnrd02> <1111574207.72969@athnrd02> <42414f88$0$9217$9b4e6d93@newsread4.arcor-online.net> <1111576802.823362@athnrd02> <1111577078.934620@athnrd02> <1111586334.958702.249050@o13g2000cwo.googlegroups.com> <1111608867.922129@athnrd02> NNTP-Posting-Host: athnrd02.forthnet.gr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: athprx02.forthnet.gr 1111631889 14495 193.92.150.73 (24 Mar 2005 02:38:09 GMT) X-Complaints-To: abuse@forthnet.gr NNTP-Posting-Date: Thu, 24 Mar 2005 02:38:09 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en In-Reply-To: Cache-Post-Path: newsfd02!unknown@ppp16-adsl-51.ath.forthnet.gr Xref: g2news1.google.com comp.lang.ada:9871 comp.lang.c++:46972 Date: 2005-03-24T04:38:09+02:00 List-Id: Jim Rogers wrote: > One Ada feature that cannot be implemented through any container library > is the ability to define a range-restricted floating point type. You can > do this in C++, but not through the use of a template. Templates cannot > take floating point values as parameters. > > For instance, in Ada it is trivial to define a floating point type with > 10 decimal digits of precision and all values in the range of 0.0 through > 1.0. > > This sort of type is very useful for defining normalized values. > > type Normalized is digits 10 range 0.0..1.0; > > I used this technique for robotic control systems. The value read > from a joystick indicating a turn could be normalized, sent across > an RF link to the robotic vehicle, and then converted to the dynamic > range available to the target actuator. The joystick could employ a > 14-bit a/d converter, or it could employ a 10-bit a/d converter. The > actuator never saw a difference. The joystick output was decoupled > from the actuator input while providing excellent control > capabilities. > > The compiler could ensure that all normalized values were within > the required range of 0.0 through 1.0. This allowed me to eliminate > explicit error checking in my code while retaining data correctness. There are C++ libraries that provide such functionality. I suppose one of them is GMP: http://www.swox.com/gmp http://www.swox.com/gmp/manual/Floating-point-Functions.html#Floating-point%20Functions -- Ioannis Vranos http://www23.brinkster.com/noicys