Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

guidance reqired in Hi-Tech C

Status
Not open for further replies.

prmurthy

Full Member level 5
Joined
Feb 13, 2009
Messages
243
Helped
38
Reputation
76
Reaction score
34
Trophy points
1,308
Activity points
2,770
Hello everybody,

I have a doubt about the return value in a c function in one of the code that does not belongs to me.

the code is :

float A (float B)
{
float X = 1.005;
float Y = 123456;
float Z = 2;
float C;

C = B x (X/Y)/Z x 100;

return (0);
}

Now i am in doubt what it returns in "return(0)"

Thankyou
 

I bet it returns the float 0.0 (at least it should, as any [good] compiler would).
 

Yes I agree with you it is returning 0. If i replace 0 with any other variable then it results that variable. But in actual code alongwith other functions it returns the float A. If I replace the 0 with any variable it results with that variable. My doubt was as to what exactly that return will do there or return in such cases used for. Can anybody explain me how the returns works and where it has to be used.
Thankyou.
 

Hmm... I'm not sure I follow you, nor understand your dilemma...

In your code A is a function taking a float (parameter B) and returning a float (0.0). I see no other way of interpreting this…

If you call A somewhere, like this:

Code C - [expand]
1
float f = A(3.74);


you’ll get f = 0.0.

In fact, this example is so trivial that the compiler should even replace the function call with the constant 0.0, if optimisations are allowed.

Are we not on the same frequency?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top