| |
GeekInterview.com > Interview Questions > Programming > C
| Print | |
Question: Fix Function
Answer: Write the implementation of Fix function? fix(2.5) = 2 and fix(-2.25) = -3, this is the expected result. Write the code to implement this behaviour? |
| March 03, 2009 01:10:44 |
#4 |
| seemakadavan |
Member Since: March 2009 Total Comments: 2 |
RE: Fix Function |
int FixUp(float value) { int fixVal;
fixVal = (int)value; if (value < 0) { if(value < (float)fixVal) { fixVal = fixVal - 1; } } return fixVal; }
|
| |
Back To Question | |