I am a new programmer and I am trying to write a funtion which does an equation then determines if it is a float, or decimal number. If it is then it needs to be rounded up to the next whole number. Any suggestions?
I am a new programmer and I am trying to write a funtion which does an equation then determines if it is a float, or decimal number. If it is then it needs to be rounded up to the next whole number. Any suggestions?
I'm assuming your input is text representing a number. Attempt to convert it to a double, if that fails attempt to convert it to an int. If the first attempt fails, it's not a floating-point value; if the second attempt fails, it's not an integral type either.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Since it will always round up could I use the ceil function in the cmath library?
Sure. But don't gloss over the input section. Actually, it might be better to check for integer before floating point since something like "1234" is both.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*