[comp.sys.apple] hyperC K&R standard?

grisanti@plains.UUCP (Ames Grisanti) (02/17/90)

The following program is taken verbatium from THE C PROGRAMMING
LANGUAGE, by Brian W. Kernigan and Dennis M. Ritchie.


/* print Fahrenheit-Celsius table
 * for f = 0, 20,..., 300
 */
main()
{
    int lower, upper, step;
    double fahr, celsius;
 
    lower = 0;          /* lower limit of temperature table */
    upper = 300;        /* upper limit */
    step = 20;          /* step size */
 
    fahr = lower;
    while (fahr <= upper) {
         celsius = (5.0/9.0) * (fahr-32.0);
         printf("%4.0f   %6.1f\n", fahr, celsius);
         fahr = fahr + step;
    }
}

Can anyone tell me why this will not compile under PRODOS
HyperC?


Ames Grisanti
[grisanti@plains.NoDak.edu      --         Internet]
[grisanti@plains or ndsuvax     --         Bitnet  ]
[uunet!plains!grisanti          --         UUCP    ]

nagendra@bucsf.bu.edu (nagendra mishr) (02/18/90)

I'm not sure about hyperC but maybe you have forgotten to 
#include <stdio.h>

exactly what error does it give you?

gwyn@smoke.BRL.MIL (Doug Gwyn) (02/18/90)

In article <3452@plains.UUCP> grisanti@plains.UUCP (Ames Grisanti) writes:
>Can anyone tell me why this will not compile under PRODOS HyperC?

I suspect HyperC doesn't support floating point.
We told you not to waste your time with it..

greyelf@wpi.wpi.edu (Michael J Pender) (02/18/90)

In article <12174@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:
>In article <3452@plains.UUCP> grisanti@plains.UUCP (Ames Grisanti) writes:
>>Can anyone tell me why this will not compile under PRODOS HyperC?
>
>I suspect HyperC doesn't support floating point.
>We told you not to waste your time with it..

It does if you use the floating point libraries, as described in the
file READ.ME

bchurch@oucsace.cs.OHIOU.EDU (Bob Church) (02/19/90)

> 
> The following program is taken verbatium from THE C PROGRAMMING
> LANGUAGE, by Brian W. Kernigan and Dennis M. Ritchie.

> main()
> {
>     int lower, upper, step;
>     double fahr, celsius;
>  
>     while (fahr <= upper) {
>          celsius = (5.0/9.0) * (fahr-32.0);
>          printf("%4.0f   %6.1f\n", fahr, celsius);
> }
	[various lines of the program deleted] 
> Can anyone tell me why this will not compile under PRODOS
> HyperC?
> 
> 
> Ames Grisanti

I don't use Hyperc but it's a pretty safe guess that your problem lies
in using floating point integer. Doubles are fp and if a compiler/linker
supports them at all you generally have to use special libraries etc. 
For the sake of experimentation change the doubles to int and change the 
numbers containing decimal places to integers. The results won't be correct
but this will help narrow down the problem.


********************************************************************
*                                                                  *
*   bob church  bchurch@oucsace.cs.ohiou.edu                       *
*                                                                  *
*  If economics isn't an "exact" science why do computers crash    *
*  so much more often than the stock market?                       *
*                                          bc                      *
********************************************************************

cyliao@eng.umd.edu (Chun-Yao Liao) (02/20/90)

In article <8502@wpi.wpi.edu> greyelf@wpi.wpi.edu (Michael J Pender) writes:
>In article <12174@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:
>>In article <3452@plains.UUCP> grisanti@plains.UUCP (Ames Grisanti) writes:
>>>Can anyone tell me why this will not compile under PRODOS HyperC?
>>
>>I suspect HyperC doesn't support floating point.
>>We told you not to waste your time with it..
>
>It does if you use the floating point libraries, as described in the
>file READ.ME

I did, but it still gave me an erro... like not a union or structure, or some
thing like that. Yes, i did included the fp.h
Any clue?

Thanx for anyhelp.

--
|I want Rocket Chip 10 MHz, Z-Ram Ultra II, UniDisk 3.5 | cyliao@wam.umd.edu  |
|I want my own NeXT, 50MHz 68040, 64Mb RAM, 660Mb SCSI, |    Chun Yao Liao    |
|              NeXT laser printer, net connection.      | Accepting Donations!|
/* If (my_.signature =~ yours)  coincidence = true; else ignore_this = true; */

reeder@reed.UUCP (Doug Reeder) (02/20/90)

In article <3452@plains.UUCP> grisanti@plains.UUCP (Ames Grisanti) writes:

>The following program is taken verbatium from THE C PROGRAMMING
>LANGUAGE, by Brian W. Kernigan and Dennis M. Ritchie.

>/* print Fahrenheit-Celsius table
> * for f = 0, 20,..., 300
> */
...

The compiler itself will only allow you to declare floats and doubles and
assign values to them.  If you want to do math with them or print them out,
you must use the stuff on the /FP/ disk (see the file README). The floating
point stuff does work, but since it's all done with functions, it's really
icky.  I can post a working floating point program if people want to see an
example.

-- 
Doug Reeder                                   USENET: ...!tektronix!reed!reeder
from ARPA: tektronix!reed!reeder@berkeley.EDU BITNET: reeder@reed.BITNET
the Little Mermaid on materialism:
I just don't see how a world that makes such wonderful things ... could be bad!

samt@pro-europa.cts.com (Sam Theis) (02/20/90)

In-Reply-To: message from grisanti@plains.UUCP

Ames Grisanti writes:


>The following program is taken verbatium from THE C PROGRAMMING
>LANGUAGE, by Brian W. Kernigan and Dennis M. Ritchie.
 
  (program segment deleted)

>Can anyone tell me why this will not compile under PRODOS
>HyperC?
 
The base level of Hyper C does not support floating point.  So %f and 5.0, etc.
don't make the compiler happy.  They were developing a floating point
extension when they went under, but I have heard that it was "completed" and
have heard reports on its availability.  
 

UUCP: crash!pro-europa!samt
ARPA: crash!pro-europa!samt@nosc.mil
INET: samt@pro-europa.cts.com