View Single Post
Old Oct 21st, 2006, 4:00 PM   #7
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,869
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
The function "sqrt" accepts an integer value. You are giving it a float. This can be fixed by using the function "sqrtf". The "f" on the end is there because it will accept a float as its parameter, just as "sqrtl" accepts a long integer.

New Code:
C = ( A * A ) + ( B * B ) ; 
C = sqrtf (C) ;

And I don't want to confuse you, but it's important to note that it can also be rewritten as:
C = sqrtf ( ( A * A ) + ( B * B ) );
This has to do with the "transitive" property of mathematics, as it applies to computer programming. Essentially, anything that's equivilent, can be restated wherever it applies.
Sane is online now   Reply With Quote