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=2.3 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_REPLYTO,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,ba9a717d172afa4f,start X-Google-Attributes: gid103376,public From: N J Chackowsky Subject: School Assignment--Can this be simplified? Date: 2000/08/30 Message-ID: <39AD5DBD.972C97CA@brandonsd.mb.ca>#1/1 X-Deja-AN: 664432542 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: admin@mts.net X-Trace: news2.mts.net 967660948 206.45.76.53 (Wed, 30 Aug 2000 13:42:28 CDT) Organization: MTS Internet MIME-Version: 1.0 Reply-To: nick@arcticmail.com NNTP-Posting-Date: Wed, 30 Aug 2000 13:42:28 CDT Newsgroups: comp.lang.ada Date: 2000-08-30T00:00:00+00:00 List-Id: Hello... I'm about to teach ADA95 for the first time, and I've come up with an assignment which helps students encode formulas. I'm using a formula to translate from temperature and dew point to relative humidity. The trouble is, I need to use the Pow function, so I need with ada.numerics.aux. Does this look about right, and could it be simplified. --HUMIDITY.ADB ----------------------------------------------------------------------- --| Calculates and displays the relative humidity based on --| the temperature and dew point. --| --| Author: N J Chackowsky, Brandon School Division No. 40 --| Last modified: 2000 08 30 ----------------------------------------------------------------------- with ada.text_io; with ada.integer_text_io; with ada.float_text_io; -- Normally, we'd use ada.numerics, but we also need the Pow, Double, and Float -- functions. Ada.Numerics.Aux contains these. with ada.numerics.aux; use ada.numerics.aux; procedure humidity is tempc, tempk : float; -- temperature in C and K dewc, dewk : float; -- dew point in C and K vp, svp : float; -- vapour pressure and saturated vapour pressure rh : float; -- relative humidity begin -- Get the temperature and dew point ada.text_io.put(item => "What is the temperature in degrees Celcius? "); ada.float_text_io.get(item => tempc); ada.text_io.put(item => "What is the dew point in degrees Celcius? "); ada.float_text_io.get(item => dewc); -- Convert from C to K tempk := tempc + 273.15; dewk := dewc + 273.15; -- Calculate vapour pressure and saturated vapour pressure vp := float(pow(2.7183, double(-5438.0 / dewk + 21.72))); svp := float(pow(2.7183,double(-5438.0 / tempk + 21.72))); -- Calculate relative humidity. Multiply by 100.0 for display as a % rh := vp / svp * 100.0; -- Display results ada.text_io.put(item => "The relative humidity is "); ada.float_text_io.put(item => rh, fore => 1, aft => 1, exp => 0); ada.text_io.put(item => "%"); end humidity; Question: Why do I need the double( ) around the expression -5438.0/dewk+21.72, but not around the literal 2.7183? Thanks for any input. Nick.