Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!ria!braille.uwo.ca!bill From: bill@braille.uwo.ca (Bill Carss) Newsgroups: comp.sys.apple2 Subject: Re: Help with Floats in Hyper C Message-ID: <.677689767@braille.uwo.ca> Date: 23 Jun 91 15:09:27 GMT References: <863@generic.UUCP> <16493@smoke.brl.mil> Sender: news@ria.ccs.uwo.ca Lines: 62 gwyn@smoke.brl.mil (Doug Gwyn) writes: >In article <863@generic.UUCP> ericmcg@pnet91.cts.com (Eric Mcgillicuddy) writes: >>> printf("%3.0f %6.1f \n, fahr, celsius"); >>>bill@braille.uwo.ca >>Certain compilers automatically coerce variables from one type to another, >>HyperC does not. >While it may be true that Hyper C does not correctly implement a translator >for programming language C, perhaps the real problem is the totally >incorrect printf() invocation as quoted above. Mr. Gwyn points out (as many have) that my printf() statement was wrong. As I have mentioned in subsequent posts (and letters to various writers), I made a typing mistake nothing more. Anyway, be that as it may, that is NOT the major source of problems for this program in Hyperc. Fortunately a solution has been found and I shall list it now. #include #include /* Convert Fahrenheit to celsius in the range 0, 20, ..., 300 */ /* ported by Andy Werner from an example in C PROGRAMMING LANGUAGE by Kernighan and Ritchie to HyperC and its SANE extension */ main() { EXTENDED temp1; INT lower, upper, fahr, step, temp2; TEXT buf[80]; lower = 0; upper = 300; step = 20; fahr = lower; while (fahr <= upper) { EXTENDED f1 = Extended(5.0); EXTENDED f2 = Extended(9.0); EXTENDED subtrahend = Extended(32.0); temp2 = fahr; cvitox(temp1, temp2); fsubx(temp1, subtrahend); fdivx(f1, f2); fmulx(f1, temp1); fptostr(buf, f1, 'x', 6, NO); printf("fahr = %d, celsius = %s \n", fahr, buf); fahr = fahr + step; } } This program works!! My thanks to Andy Warner for his coding expertise. As far as Mr. Gwyn's comment is concerned well .... obviously he knows as much (or as little) about HyperC as I do. -- Bill Carss bill@braille.uwo.ca