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: Help with Floats in Hyper C Summary: Explanation of how to use floats in Hyper C wanted. Keywords: float, EXTENDED, invalid expression Message-ID: <.677021512@braille.uwo.ca> Date: 15 Jun 91 21:31:52 GMT Sender: news@ria.ccs.uwo.ca Distribution: na Lines: 54 I am just beginning to learn C. I am using K&R and have FINALLY started to work my way through the text as I learn the language. The float problem cropped up in the thrid program discussed. It is simply a program to convert fahrenheit temperatures to celsius and to get a little more accuracy than int's provide, they suggest declaring fahr and celsius as ftype float. The program is as follows: #include /* I changed the name of std.h for compatability */ #include /* Convert Fahrenheit to celsius in the range 0, 20, ..., 300 */ main() { float fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; fahr = lower; while (fahr <= upper) { celsius = (5.0/9.0) * (fahr-32); printf("%3.0f %6.1f \n, fahr, celsius"); fahr = fahr + step; } } I typed in the above program and got an error message telling me that the "fahr = lower;" line was not a pointer. I have a friend is is an experienced C programmer (he has a couple of commercial packages to his name) and he suggested casting in the form fahr = (float)lower; This resulted in an error message relating to the while statement such that it was invalid. I have done some reading of the documentation that I have and have found nothing much to do with "float"s other than the fact that they are not ever defined (that I can find) and it is necessary to convert them to other things to use them. There are functions like cvxtoi (and the reverse), but I thought PPF should take care of that for me. Any halp anyone can give me would be greatly appreciated. -- Bill Carss bill@braille.uwo.ca