# intceil

## Reasoning

ceil() and floor() do not operate properly for x < 0. int() (as well as mod()) is not generally available in scientific calculators, but should be. an integer version of ceil and floor is needed. fmod can be substituted for % with the same effect, then also numerator and denominator types can be long double.

these functions should work for -x or +x or 0. it is like ceil for +x but with floor for -x (that is another way to do it).

God gave me the idea for this.

## C++

`intmax_t intceil(intmax_t numerator, intmax_t denominator) {return intmax_t(numerator/denominator) + (numerator%denominator<0?-1:0) + (numerator%denominator>0)?1:0);}`

``` #include <math.h> #include <stdint.h> //replacements for ceil and floor. typedef long double LongDouble;//80-bit floating point intmax_t intnext(intmax_t numerator, intmax_t denominator) { return intmax_t(numerator/denominator) + (numerator%denominator<0?-1:0) + (numerator%denominator>0?1:0); } intmax_t floatnext(long double numerator, long double denominator) { return (0==denominator?0:intmax_t(numerator/denominator)) + //avoids divide overflow (fmodl(numerator,denominator)<0)?-1:0) + (fmodl(numerator,denominator)>0)?1:0); } long double floatnextfloat(long double numerator, long double denominator) { return ((denominator==0?0:LongDouble(numerator)/LongDouble(denominator)) - //avoids divide overflow fmodl(numerator,denominator) + (fmodl(numerator,denominator)<0)?-1:0) + (fmodl(numerator,denominator)>0)?1:0); } //either way, ceil or float is supposed to return an integer value. //the reason explanation (booleanCondition?trueValue:falseValue) is an ternary if statement that gives trueValue or falseValue based on the booleanCondition's evaluation. I learned from mathematics books that there is in math an IF statement. this function is based upon that statement. (fmod(numerator,denominator)<0)?-1:0) + (fmod(numerator,denominator)>0)?1:0) or (numerator%denominator<0?-1:0) + (numerator%denominator>0?1:0)is renderable in mathematics as: the first ternary if is: if denominator = 0 => 0 otherwise intmax_t(numerator/denominator) or if denominator = 0 => 0 otherwise ((denominator==0?0:LongDouble(numerator)/LongDouble(denominator)) - fmodl(numerator,denominator) if mod(numerator,denominator) < 0 =gt; -1 if mod(numerator,denominator) > 0 =gt; +1 if mod(numerator,denominator) = 0 =gt; 0 ```
``` http://JesusnJim.com/math-research/intnext.html   <———URL to this document ```