Re: [C]

From: Angus Mezick (angus@EDGIL.CCMAIL.COMPUSERVE.COM)
Date: 10/07/97

try a= 10.0/100.0
or try a= (float)10/(float)100;
(hint: 10 and 100 are ints in the example below)
______________________________ Reply Separator _________________________________
Just a short question here about floats with ANSI C on AIX.

This is an example of something I was trying to do.

float a;

a = 10 / 100;

'a' always comes back as 0. I've found a workaround for it but I was
just curious if floats have to have a whole number part or if I was just
doing something wrong. The formula was more complex but it would have
produced a number between 0.01 and 0.99. On paper it should have anyway.
But as soon as I divided by 100, the var became 0. I'm also curious if
it can't be done like this, how is it supposed to be done...

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/08/00 PST