Questions tagged [ceil]

A function common to many programming languages that returns the next integer value by rounding the value up if necessary.

Returns the next highest integer value by rounding up value if necessary. php.net

Examples

echo ceil(1.3);    // returns   2
echo ceil(10.9);   // returns  11
echo ceil(-3.14);  // returns  -3
301 questions
-1
votes
1 answer

ceil() function in C does not return expected value

double res; res = ceil(363.5); res is 1031 instead of 364 as expected. Does anyone know the reason? And how can I use the function ceil() and get the expected result?
-1
votes
1 answer

Calculation error while using ceil function in C++

I m new to C++. I m trying to implement a segmented sieve to find prime numbers, between given numbers m and n. My logic might be also wrong. Below is the code i have written, long long m; long long n; std::cin >> m; std::cin >> n; vector
m_amber
  • 747
  • 3
  • 13
  • 23
-1
votes
6 answers

SQL Server calculation, how to modify?

We are doing the following sql server calculation: SELECT SUM(COALESCE(ceiling(xm.datapoints / 8) + 1, 1) Problem is that we shouldn't always add + 1 to the ceiling value. If xm.datapoints % 8 > 0 then we should add + 1. If xm.datapoints % 8 = 0…
user2500179
  • 291
  • 1
  • 2
  • 6
-2
votes
1 answer

Ceil any number in python this way - 2.3, 2.1, 1.9, 2.6. to 2.5, 2.5, 2, 3 i.e. addition leads to addition of .5 or 1 whichever is closest

Default ceiling doesn't work this way. Ceil should work in this way - Example 2 - 3.1, 4.5, 5.9 after ceiling - 3.5, 4.5, 6
-2
votes
2 answers

Why floor and ceil functions giving different values when applied on a log function result in c++

Below is the program I've written to find the exponent of 6, but I this its giving wrong output or I may be wrong somewhere, I'm unable to figure out here. #include using namespace std; #define ll long long int main() { ll t; …
aksr
  • 322
  • 1
  • 2
  • 11
-2
votes
1 answer

outputting the middle element(s) of matrices in R

I'm really stuck on this problem: Please help. Create a code that takes a matrix as an input and outputs the middle element of the matrix. (hint: think about floor and ceiling functions)
cate
  • 11
-2
votes
2 answers

Python : round a decimal number

I'm getting a number in my software and I would like to apply a process if this number is a decimal number. I would like to round my number to the upper entire number. For example : Get number --> expected 1.3 --> 2 1.7 --> 2 2.0 --> 2 2.1 --> 3 Is…
Essex
  • 6,042
  • 11
  • 67
  • 139
-2
votes
1 answer

math.ceil returns float (1.5)

I need a ceil of a float which it doesn't give to me! Here is the part of the code: ne = j + e nk = ne / 6 int(math.ceil (nk)) p2 = nk * 11 if p2 < p1: p1 = p2 print (p2) j, e and p1 already have values (in this case…
Banana
  • 21
  • 1
  • 4
-2
votes
1 answer

Rounding off floating point value in C++ without using build in functions

I think truncating can be done by converting float to int e.g 25.83f will be 25 when converted to int but it should be 26 when rounded off..how this can be achieved please help me thanks Similarly I think ceiling can be done by converting to int…
Muhammad Awais
  • 1,608
  • 1
  • 21
  • 21
-2
votes
1 answer

How to use limitTo with math expression (angular)

I'm trying to develop some pagination buttons using ng-repeat like this:
  • {{(Math.ceil(indexN+1/10))}}
  • This code checks how many items…
    -3
    votes
    1 answer

    How to pass an expression as input and it gives the ceil value as the output?

    a. In variables a,b gets the input from the user so as to evaluate the expression from the given input and it gives the ceil and floor values as the output. def ceil_flooor(): a = float(input()) b = float(input()) …
    Mounika
    • 15
    • 4
    -3
    votes
    1 answer

    Python ceil function not returning a int, returning floats instead

    number = 1.23456789 import math math.ceil(number) print(number) Expected outcome is 2, instead the return is the original input of 1.234567. I'm learning Python and this is my fourth assignment, the professor even says in their own textbook to…
    Kierwynn
    • 17
    • 4
    -3
    votes
    1 answer

    JAVA - double issue - ceil and floor functions

    I need to solve the issue related to the double representation. For example, I have the following set of values: id: 1 val: 8.11 floor: 8.109999 ceil: 8.11 id: 2 val: 8.31 floor: 8.31 ceil: 8.310001 id: 3 val: 8.27 …
    Fab
    • 1,145
    • 7
    • 20
    • 40
    -3
    votes
    2 answers

    The output of ceil() and floor() in C language is odd

    I am doing my homework to realize a C programe and during my work there is one step that I need to get the interger part of the double type numbers. So I choose ceil() or floor() in to realize this. But the output is unpredictable and far from…
    sikisis
    • 458
    • 9
    • 21
    -4
    votes
    5 answers

    With PHP, how to check if decimal number is above or less than 50?

    I am trying to check if a number which is inside a variable got a decimal number above 50 , or less than 50. Then depending on if it's 50 or higher, round the decimal number to 99 , and if it's less, round it to 00. Here is a piece of my…
    mlclm
    • 725
    • 6
    • 16
    • 38
    1 2 3
    20
    21