[comp.lang.c] Floating variables

wozniak@utkux1.utk.edu (Bryon Lape) (11/27/89)

	In C, are floating point numbers allowed to hold negative
numbers?  I am trying to convert a BASIC programme and I must have
negative calculations for floating point numbers.  So far the fern leaf
is not generating.


-bryon-

gwyn@smoke.BRL.MIL (Doug Gwyn) (11/30/89)

In article <1404@utkcs2.cs.utk.edu> wozniak@utkux1.utk.edu (Bryon Lape) writes:
>In C, are floating point numbers allowed to hold negative numbers?

Of course.

>I am trying to convert a BASIC programme and I must have negative
>calculations for floating point numbers.  So far the fern leaf is not
>generating.

I can't help you with gardening, but in C you need to be careful
when converting floating-point to integer type; some implementations
truncate toward zero, others toward minus infinity.  Also, don't
expect the result of a floating-point calculation that "should" be
an exact integer value to actually be one.  You might get 0.9999999
instead of 1.0000000, and truncation of this will surprise you.