Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sdd.hp.com!hp-pcd!hpcvia!brianh From: brianh@hpcvia.CV.HP.COM (brian_helterline) Newsgroups: comp.lang.c Subject: Re: Paramters of type float getting corrupted in Microsoft C 5.1. HELP !!! Message-ID: <31530024@hpcvia.CV.HP.COM> Date: 31 Oct 90 16:34:50 GMT References: <6947@castle.ed.ac.uk> Organization: Hewlett-Packard Co., Corvallis, Oregon Lines: 35 elee24@castle.ed.ac.uk (H Bruce) writes: >I am having a problem with Microsoft C (V 5.1). >When I pass a parameter of type float (by value) to a function, by the time >it is read from the stack by the function it is corrupted. >The corrupted value is something very small (eg X.XXXXe-XXX) and varies >depending on the parameter. [rest of desription deleted] One possible source of problems is are you using prototypes and/or old style function declarations? If so, your floats are actually being passed as doubles which will mess things up. As an example: int foo(float, float, int); /* prototype */ int main() { float x,y; int i; ..... result = foo( x, y, i ); } int foo( x, y, i ) /* old stype declaration */ float x,y; /* floats are really double */ int i; { ... } If this is the case, either 1) use ANSI function declaration, or 2) change your prototype to double (If you generate prototypes using the /Zg option with MSC, the prototypes actually come out as being doubles!)