Is it possible to calculate the ceiling (for example, ceil(2.12) = 3 ) with only a few available arithmetic operations: * - + / That is, without castings and other program tricks, only using the division / multi / sub / addition and comparison operators?
Explanations:
- Complexity is important, but I will be happy to hear any decisions.
- The module is unavailable.
- The values ββare positive.
- Operations are not rounded.
- With software tricks, I meant mod, bit level manipulation, etc.
Basically, I have a system that allows you to assign expressions to variables, where an expression can only contain the 4 arithmetic operations, comparisons, and loops listed above. For instance.
var x = if (A * (1.434 + 0.4325))> 54.4534), then 45.6 otherwise 43.435
and i would like to do
var x = CEIL (...)
source share