The functions ceil() and floor() will return different numbers than what you get by using
up = (int)(test + 1);
down = (int)test;
when you have a negative number.
If you have:
float test = -1.3548;
up = (int)test; // ceil()
down = (int)(test-1); // floor()
Even the last statement is not a good way to compute floor() when test is an integral number.
Unless you want to deal with positive and negative numbers differently, and the special cases of when test is integral number, you are better off using ceil() and floor().
Floor and ceil function - Post.Byes - Bytes
Looking for a kind soul to assist with 'floor' and 'ceil' in C++
Programming FLOOR & CEIL
Flooring and ceiling integers in C
How do you use ceil and floor?
What is the ceil() function in C?
What is floor () vs ceil ()?
Videos
Soooo, I am very green/new to any type of code and programming. I understand the base concept of the floor/ceil. Functions but unsure how to incorporate them to my current code. I can give brief details of deliverables. Prompt user to input 2 values to be converted from Celsius to Fahrenheit. Determine which of the 2 is the "start/stop" values. Once start and stop are determine, the program converts every value in the range input from user to Fahrenheit, in 1 degree increments.
I have all of the code complete.. my issue is floor and ceil functions just won't round up or down as expected. Not proficient enough to determine where my code needs to be tweaked. Please help. Thank you. The "start" value should round down and the stop value should round up. My code either rounds both up or down.
Willing to elaborate more if the above doesnt make sense.. with anyone willing to help.