Floating variables

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Nov 30 06:45:10 AEST 1989


In article <1404 at utkcs2.cs.utk.edu> wozniak at 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.



More information about the Comp.lang.c mailing list